Could not find a file named "pubspec.yaml" - flutter

hi friends how to solve this error,i'm just running this command flutter:
Flutter doctor -v,
flutter pub cache clean ,
flutter pub cache repair,
flutter packages pub get,
flutter clean,
dart pub get ,
flutter pub get,
i'm getting an error
Could not find a file named "pubspec.yaml" in "E:\flutter.pub-cache\hosted\pub.dartlang.org\test_api-0.4.8".
Running "flutter pub get" in flutter_tools...
pub get failed (66; Could not find a file named "pubspec.yaml" in
"E:\flutter.pub-cache\hosted\pub.dartlang.org\test_api-0.4.8".)

I had this same issue. Really frustrating.I deleted the pub.dartlang.org folder.
On Mac, in finder command + shift + G | pasted the path from the console | opened in finder and removed the folder.
after deleting the folder
run
Pub get
pub outdated / upgrade
pod repo update
pod update
This fixed my issue and allowed me to build the app.

Related

pub run build_runner build has error (66)

hey guys i have error after using command : flutter pub run build_runner build
error message :
C:\Users\matin\AndroidStudioProjects\mosito>flutter pub run build_runner build
Could not find a file named "pubspec.yaml" in "C:\Users\matin\Documents\flutter\.pub-cache\hosted\pub.dartlang.org\async-2.8.1".
pub finished with exit code 66
i try flutter pub upgrade and a lot of things from google but problem not fixed
NOTE: im new to flutter i want use this command for making .g.dart file for my models thanks for your attention
I think may be you are not in your project directory. Suppose you have a project name A in myfolder in C drive of your computer. First goto myfolder with terminal. after that try below code to build the project...
flutter packages pub run build_runner build --delete-conflicting-outputs
Turn on Your Terminal and Run
flutter doctor
if it is showing
Could not find "flutter"
Then you need to install flutter Correctly You Can check :
https://docs.flutter.dev/get-started/install/windows

Pub failed to rename directory because access was denied

Whenever I run flutter doctor or flutter pub get, I am getting the following error
Pub failed to rename directory because access was denied.
This may be caused by a virus scanner or having a file in the directory open in another application.
Running "flutter pub get" in flutter_tools...
pub get failed (1; in the directory open in another application.)
I have tried some commands, ran the commands in administrator mode, but still getting the same error.
For me it helped to delete the 'pubspec.lock' file in the project folder and the run flutter pub get again
The source of my problem was that I had flutter installed directly in the C directory. After moving it to another directory (worked for me under MyUser/Downloads) the problem was solved.
I also faced a similar problem.
so, running flutter clean in terminal solved the problem.
I have deactivated my Anti-Virus and it worked for me! - Deactivate Antivirus

flutter pub get won't download dependency

I deleted a package manually from Dart Package directory and deleted pubspec.lock. Now when I do flutter pub get it does not download that package again. I tried flutter clean && flutter pub get but it's not working as well. Please help I can't build my project now.
You can try to close and then open the editor and try:
flutter clean
flutter packages get
flutter packages upgrade

The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again

I try to run test on codemagic with custom pre-test script. And this is my pre-test script:
#!/bin/sh
cd libraries
cd dependencies
flutter pub get
cd ..
cd core
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd ..
cd features
cd splash
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd proposal
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
And this I my flutter project structure:
But when the pre-test is running, I get this error:
Running "flutter pub get" in dependencies... 2.5s
Running "flutter pub get" in core... 4.9s
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65
Running "flutter pub get" in splash... 3.0s
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65
Running "flutter pub get" in proposal... 3.2s
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65
Build failed :|
Step 4 script `Pre-test script` exited with status code 65
I think this error is because of flutter pub run build_runner build --delete-conflicting-outputs when I want generated .g.dart file via codemagic.
I try to google but still not found a solution, can someone help me how to solve this error on codemagic?
I fix with add flutter pub run twice.
#!/bin/sh
cd libraries
cd dependencies
flutter pub get
cd ..
cd core
flutter pub get
flutter pub get // add again
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd ..
cd features
cd splash
flutter pub get
flutter pub get // add again
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd proposal
flutter pub get
flutter pub get // add again
flutter pub run build_runner build --delete-conflicting-outputs

flutter 'file not found' during build for ios

I'm trying to use the image_picker_web package,(https://pub.dev/packages/image_picker_web) and have put:
image_picker_web: ^1.0.9
in my pubspec.yaml file.
When I try building my project for iOS, I get the following error:
[ios/.symlinks/plugins/image_picker_web/example] flutter pub get
Running "flutter pub get" in example...
Cannot open file, path = '/Users/username/.pub-cache/global_packages/image_picker_web_example/pubspec.lock' (OS Error: No such file or directory, errno = 2)
pub get failed (66; Cannot open file, path = '/Users/username/.pub-cache/global_packages/image_picker_web_example/pubspec.lock' (OS Error: No such file or directory, errno = 2))
exit code 66
With no other code in the project that uses that package, I get the same error. The only way to avoid it is to comment out image_picker_web: ^1.0.9 in my pubspec.yaml and run 'flutter pub get'
I created an issue in their git repo, under the assumption that it's a bug. Is this the case? Are there any workarounds? (perhaps ignoring a package when building for a different platform?)
I ran the following command to fix a similar issue.
Remove all existing caches
sudo rm -rf ~/.pub-cache
Repair the cache
flutter pub cache repair
Reinstall the dependencies
flutter packages get