salah112
salah112

Reputation: 161

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

Upvotes: 16

Views: 56431

Answers (24)

raVen
raVen

Reputation: 73

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 works.

Upvotes: 0

Ali Pashaamiri
Ali Pashaamiri

Reputation: 1

if you're on windows first run cmd as administor then run flutter pub cache clean then run flutter run -d <your-device> it should work if your'e on mac or linux do the run part using sudo

Upvotes: 0

code8x
code8x

Reputation: 1970

In my case it was a permission problem that error code so I just run chmod command for that particular project's folder and the problem gone. Change permission code as your requirements, in my case it wasn't an important project.

sudo chmod -R 777 .

Upvotes: 1

ahmnouira
ahmnouira

Reputation: 3391

Fixed

Doing an upgrade to flutter fix this:

flutter upgrade

Upvotes: 0

Rasha Mohamed
Rasha Mohamed

Reputation: 154

I delete pubspec.lock file , then

flutter pub get

Upvotes: 0

MrOrhan
MrOrhan

Reputation: 1114

I had the same problem, when I tried to run the official sample code for flutter web "Gallery".

My solution was to upgrade to master. Run "flutter channel master". But take care, since after running this, you will switch to the master channel. I recommend to switch back to the stable channel, as soon as possible again. Because the master channel could have some hard bugs.

Upvotes: 0

Savita Patil
Savita Patil

Reputation: 1

try this, it solved my error,

terminal->flutter clean, then flutter pub get after this, you will get the reason for the error, in my case I was using the latest version of path dependencies(path ^1.8.3), but SDK depended on the path ^1.8.2, so I changed path dependency from path ^1.8.3 to path ^1.8.2, in pubspec.yaml, and the error was solved...

Upvotes: 0

Ashwin R
Ashwin R

Reputation: 11

All the above solutions didn't work for me So I tried this

I removed pubspec.lock file and run flutter pug get

Upvotes: 0

Shimon Doodkin
Shimon Doodkin

Reputation: 4569

My solution was to run

flutter pub get 

it in an external terminal not from android studio

Also I set windows as developer, I ran in terminal and turned developer mode on

start ms-settings:developers

not sure which one helped.

Upvotes: 0

YunHan
YunHan

Reputation: 101

I have tried Flutter clean X Flutter pub cache repair X Add Security X Delete Temp X

last ....
I just open the windows setting developer mode O enter image description here

Upvotes: 0

chickahoona
chickahoona

Reputation: 2034

Enable in your windows settings the Developer Mode. Enable Developer Mode in Windows

Upvotes: 8

Zero
Zero

Reputation: 2900

Because I switched the Flutter version, the following operation worked for me

flutter clean
flutter pub get

Upvotes: 3

vivek
vivek

Reputation: 1102

If you have tried all answers here.

You should try this, it worked for me.

  1. (in android studio) Delete the pubspec.lock file in your project.

  2. (in android studio) Execute this-- Tools > Flutter > Flutter clean

  3. Go to flutter sdk folder where you have downloaded it. In my case C:\src\flutter\

  4. 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.

Upvotes: 4

ANAS AJI MUHAMMED
ANAS AJI MUHAMMED

Reputation: 763

Turning on developer mode solved my issue on Windows 10.

  1. Delete temp folder in pub cache.
  2. Do pub repair flutter pub cache repair.
  3. Turn on developer mode in windows settings.
  4. Flutter clean and delete pub.lock if exist.
  5. Try flutter pub get.

This worked for me.

Upvotes: 4

reanmox
reanmox

Reputation: 43

An easy solution that worked for me on Windows was to run Android Studio as administrator.

After that, the error no longer appeared.

Upvotes: 3

user16473310
user16473310

Reputation: 1

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.

Upvotes: 0

oguzkaba
oguzkaba

Reputation: 1

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:

  1. flutter pub cache repair 2.flutter pub get

Upvotes: 0

Yuri Abramov
Yuri Abramov

Reputation: 161

What worked for me is: flutter pub cache repair

reference

Upvotes: 15

Riya Gupta
Riya Gupta

Reputation: 69

I downloaded flutter sdk and extracted file in C:\FlutterDev\ and then start android studio remember to provide flutter sdk path if you changed

Upvotes: 0

yalewzj
yalewzj

Reputation: 1179

Sometimes newly installed packages could cause this. Uninstall and install package again

Upvotes: 0

John Kinyanjui
John Kinyanjui

Reputation: 1204

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.

Upvotes: 9

Ashutosh Singh
Ashutosh Singh

Reputation: 1277

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.

Upvotes: 7

Lukas Marik
Lukas Marik

Reputation: 149

Try to clean Flutter: flutter clean and then update pub with: flutter packages upgrade or update Flutter with: flutter upgrade.

Upvotes: 7

Yash Jain
Yash Jain

Reputation: 415

Update the Flutter sdk using : flutter upgrade.

And also scoped_model in this link scoped model is showing dart 2 incompatible

Upvotes: 0

Related Questions