'Flutter: pub get failed (66)
When i try to implement scoped model, i get this error message:
[flutter_course] flutter packages get
Running "flutter packages get" in flutter_course...
Creation of temporary directory failed, path = 'C:\Program Files\flutter.pub-cache_temp\dir' (OS Error: Access is denied.
, errno = 5)
name: flutter_course
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
scoped_model: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
Solution 1:[1]
Solution 2:[2]
I FINALLY GOT THE SOLUTION
Hello guys I finally found a solution to this error.
So the problem is first caused because temporary files could not be created in the /bin or .pub-Cache
To fix this go to their respective folders which are in the flutter folder and the first start with the bin folder and change its security options to allow for ALL APPLICATION PACKAGES and then the .pub-Cache the same .
Run flutter doctor and if you get a license error just follow the steps given by flutter doctor and you are good to go.
Solution 3:[3]
This happens to be an active issue and the flutter team is currently working on it. The problem is specific to the Windows operating system. You can try the following workarounds for now:
1) Make sure your installation does not reside in any directory which requires special privileges like Program Files
. If that's the case, you can try running it as admin for now but you should change your installation directory to a user's data directory as soon as possible (@Günter Zöchbauer has already pointed this out in the comments).
2) Try restarting your machine.
3) Try deleting the .dart_tools
folder and also try clearing the cache in flutter/bin/cache
4) Try disabling your antivirus and/or windows defender temporarily (although it's not really possible for people working on corporate machines). This issue could have been caused by an active antivirus locking your files temporarily.
Solution 4:[4]
Try to clean Flutter: flutter clean
and then update pub with: flutter packages upgrade
or update Flutter with: flutter upgrade
.
Solution 5:[5]
An easy solution that worked for me on Windows was to run Android Studio as administrator.
After that, the error no longer appeared.
Solution 6:[6]
Turning on developer mode solved my issue on Windows 10.
- Delete temp folder in pub cache.
- Do pub repair
flutter pub cache repair
. - Turn on developer mode in windows settings.
- Flutter clean and delete pub.lock if exist.
- Try
flutter pub get
.
This worked for me.
Solution 7:[7]
If you have tried all answers here.
You should try this, it worked for me.
(in android studio) Delete the pubspec.lock file in your project.
(in android studio) Execute this-- Tools > Flutter > Flutter clean
Go to flutter sdk folder where you have downloaded it. In my case C:\src\flutter\
Run this below command.
C:\src\flutter\bin\cache\dart-sdk\bin>flutter pub cache repair
After completion run pub get again in your android studio. It should work.
Solution 8:[8]
Because I switched the Flutter version, the following operation worked for me
flutter clean
flutter pub get
Solution 9:[9]
Solution 10:[10]
Update the Flutter sdk using : flutter upgrade.
And also scoped_model in this link scoped model is showing dart 2 incompatible
Solution 11:[11]
You get this error because "packages get" command attemp to delete file in ...flutter.pub-cache_temp. Delete files manually in this loction, this is may not perfect solutions but it's works.
Solution 12:[12]
Sometimes newly installed packages could cause this. Uninstall and install package again
Solution 13:[13]
I downloaded flutter sdk and extracted file in C:\FlutterDev\ and then start android studio remember to provide flutter sdk path if you changed
Solution 14:[14]
I had a similar situation when I upgraded the flutter version to the new 2.2. As a solution, I ran the command line as administrator (or terminal for linux users) in the Project folder and run the following commands:
flutter pub cache repair
2.flutter pub get
Solution 15:[15]
I have tried all the solutions mentioned above none worked for me.
Then I went to file(any .dart) which has dependency error then click on get dependency. it works for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow