I'm receiving the following error message when trying to run tests in a dart library:
Could not find a file named "pubspec.yaml" in "/Users/deducted/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-2.2.0".
I can't provide the trace logs of running the command, as I'm now unable to reproduce the issue. Feel free to close this issue if it was already brought up. I saw some similar issues, but they always mentioned an outdated flutter version or something wrong with their own or a dependencies pubspec.yaml. In my case I don't think the issue has anything to do with me or my dependency and I also don't use flutter at all.
After running rm -rf ~/.pub-cache ; pub get everything works fine again and I can run my tests. Contrary to what I would've expected running pub cache repair didn't fix the issue.
https://github.com/flutter/flutter/issues/32033#issuecomment-552488192
Dart VM version: 2.7.2 (Mon Mar 23 22:11:27 2020 +0100) on "macos_x64"
Pub 2.7.2
name: deducted
description: deducted
version: 1.0.0+1
environment:
sdk: '>=2.7.0 <3.0.0'
dependencies:
dev_dependencies:
pedantic: 1.8.0
test: 1.14.2
mockito: 4.1.1
name: _fe_analyzer_shared
version: 2.2.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
environment:
sdk: '>=2.2.2 <3.0.0'
dependencies:
meta: ^1.0.2
dev_dependencies:
test: ^1.3.4
I'm facing other issue with testing.
getting error:
Could not find a file named "pubspec.yaml" in "C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\_fe_analyzer_shared-4.0.0".
but the file exists in path:
C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-4.0.0
any solution?
Not sure if this is related. I have the same issue when I am doing pub run test, but if I use flutter test instead, it is fine.
Tried this
dev_dependencies:
flutter_test:
sdk: flutter
test: ^1.15.3
bloc_test: ^7.0.2
And this too.
dev_dependencies:
flutter_test:
sdk: flutter
test: ^1.15.3
bloc_test: ^7.0.2
pub run test doesn't seem to work in any case throws Could not find a file named "pubspec.yaml" in "/home/pi/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-6.0.0"
Could not find a file named "pubspec.yaml" in "C:UsersuserAppData\LocalPubCache\hostedpub.dartlang.org_fe_analyzer_shared-4.0.0".
``but the file exists in path:C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-4.0.0`
I have this problem too!
Could not find a file named "pubspec.yaml" in "C:UsersuserAppData\LocalPubCache\hostedpub.dartlang.org_fe_analyzer_shared-4.0.0".
but the file exists in path: `C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-4.0.0`I have this problem too!
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):
export PUB_CACHE=C:/src/flutter/.pub-cache/bin
export PATH=$PATH:$PUB_CACHE
For me... this was resolved by
export PUB_CACHE="~/tools/flutter/.pub-cache"
(Thanks for the hint @xiaojiakai - PS: PUBCACHE setting should not have /bin at the end)
I have same problem:
Could not find a file named "pubspec.yaml" in "C:\Users\alexa\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\_fe_analyzer_shared-20.0.0".
The weird part is: There IS such a file at that location:
C:UsersalexaAppData\LocalPubCache\hostedpub.dartlang.org_fe_analyzer_shared-20.0.0pubspec.yaml
name: _fe_analyzer_shared
version: 20.0.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
environment:
sdk: '>=2.12.0-0 <3.0.0'
dependencies:
meta: ^1.0.2
dev_dependencies:
test: ^1.3.4
The following did not fix it:
rm -rf ~/.pub-cache followed by pub getflutter pub cache repairIt blocks working on my flutter project.
I am new to flutter thus out of ideas.
EDIT:
Weirdly enough deleting C:\Users\alexa\AppData\Local\Pub\Cache using the explorer or wsl had no influence. Only when I deleted it using the new powershell did it work. And get my flutter app working again ๐
So 4 days later this hits me again, though a little differently:
PS C:\Users\alexa\capturing> dart run build_runner build
Could not find a file named "pubspec.yaml" in "C:\Users\alexa\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\_fe_analyzer_shared-20.0.0".
I tried:
rmdir "C:\Users\alexa\AppData\Local\Pub\Cache": removes the cache folderdart run build_runner build: builds the Cache folder again. But WITHOUT _fe_analyzer_shared-20.0.0flutter clean: seemed not to helpThis is my pubscpec.yaml:
name: capturing
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.1.0+1
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
get: ^4.1.4
firebase_core: ^1.0.2 #nullsafe
firebase_auth: ^1.0.1 #nullsafe
flutter_progress_hud: ^2.0.0 #nullsafe
font_awesome_flutter: ^9.0.0 #nullsafe
isar: ^0.4.0 #nullsafe
isar_flutter_libs: ^0.4.0 #nullsafe
path_provider: ^2.0.1 #nullsafe
uuid: ^3.0.4 #nullsafe
dev_dependencies:
flutter_test:
sdk: flutter
isar_generator: ^0.4.0 #nullsafe
build_runner: ^1.12.2 # NOT nullsafe?
flutter:
assets:
- images/
From flutter doctor:
PS C:\Users\alexa\capturing> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โ] Flutter (Channel beta, 2.2.0-10.1.pre, on Microsoft Windows [Version 10.0.19042.928], locale de-CH)
[โ] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[โ] Chrome - develop for the web
[โ] Android Studio (version 4.1.0)
[โ] VS Code (version 1.55.2)
[โ] Connected device (2 available)
โข No issues found!
Am VERY happy for help ๐
EDIT:
I ran flutter packages pub run build_runner build instead of dart run build_runner build. THAT WORKED.
I have absolutely no idea what black magic is happening here.
I saw that this command did not build a cache folder at C:\Users\alexa\AppData\Local\Pub though.
@barbalex if you run the flutter command it will use flutters .pub-cache which may not necessarily be the same as darts .pub-cache
In fact if you run flutter pub -h you'll see that there is another command pub which states Pass the remaining arguments to Dart's "pub" tool.
So be sure to only use flutter pub or dart pub exclusively and not switch in-between for your project depending on whether it's a flutter project or a pure dart project.
Most helpful comment
So 4 days later this hits me again, though a little differently:
I tried:
rmdir "C:\Users\alexa\AppData\Local\Pub\Cache": removes the cache folderdart run build_runner build: builds the Cache folder again. But WITHOUT_fe_analyzer_shared-20.0.0flutter clean: seemed not to helpThis is my pubscpec.yaml:
From
flutter doctor:Am VERY happy for help ๐
EDIT:
I ran
flutter packages pub run build_runner buildinstead ofdart run build_runner build. THAT WORKED.I have absolutely no idea what black magic is happening here.
I saw that this command did not build a cache folder at
C:\Users\alexa\AppData\Local\Pubthough.