Alexis Acosta
Alexis Acosta

Reputation: 165

Pub failed to delete entry because it was in use by another process

I was trying to configure my Flutter project to work on the web. I switched to the master channel using flutter channel master after doing this I tried to run flutter upgrade. I am now getting an infinite loop saying:

Building flutter tool...
Running pub upgrade...
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Error (1): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)

Waiting for 0 seconds, press CTRL+C to quit ...
Running pub upgrade...
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Error (1): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)

Waiting for 2 seconds, press CTRL+C to quit ...
Terminate batch job (Y/N)? Y

I have tried multiple things such as running flutter clean, trying to change back to the stable channel, deleting the cache folder in the flutter/bin directory, turning off my windows defender, nothing seems to work. Now when I try to run flutter doctor, or any other flutter command, I get the same infinite loop with the same message. I have also tried manually downloading and replacing my flutter sdk installation with a new installation, this did not work either. Is my only option at this point to delete flutter completely and reinstall from scratch?

I would appreciate any suggestions on how to fix this.

Upvotes: 15

Views: 30039

Answers (12)

Sagar Karn
Sagar Karn

Reputation: 36

Go to setting > system > For developers

Turn on the developer mode and run the command again.

enter image description here

Upvotes: 0

Ricardo Araque
Ricardo Araque

Reputation: 81

Worked for me close all android studio tabs, after open a cmd as admin, go to your folder (if the command requires it) and execute the command again

Upvotes: 0

Muhammad Ullah
Muhammad Ullah

Reputation: 332

The only solution is to run android studio as administrator.

Upvotes: -2

Muhammad Umair Saqib
Muhammad Umair Saqib

Reputation: 1865

Running VS Code or Android Studio as Administrator, will probably solve the problem.

Upvotes: 2

Tim Wong
Tim Wong

Reputation: 1

I have solved it. I recommend instead of C:/src/flutter, you put the flutter folder inside C:/ direct. Would be like this:

C:/flutter

If that doesn't solve it, try pausing your anti-virus just for us to test. It could be that it is blocking the permissions on local disk C folder. It's not very common, but it can happen sometimes.

Upvotes: 0

Raphael Souza
Raphael Souza

Reputation: 107

On windows: Run vscode, or the terminal you are using, as admin to resolve the problem. For Linux: I think some kind of sudo approach could do the trick.

Upvotes: 10

J.Koriya
J.Koriya

Reputation: 167

Faced this problem and had to run "start ms-settings:developers" at terminal. It solved the issue.

Upvotes: 11

Arshneet Kathuria
Arshneet Kathuria

Reputation: 671

switch your channel to stable or master using command "flutter channel stable"

Upvotes: 0

Ilidio Nzage
Ilidio Nzage

Reputation: 351

I ran my compiler as an administrator, and it worked for me. Open your Android Studio or Visual Studio as an admin.

Upvotes: 34

InWahyu
InWahyu

Reputation: 11

use powershell (admin) to fix this I got same problem and fix this using Windows PowerShell (Admin). Just type flutter

Upvotes: 0

aeviou
aeviou

Reputation: 219

I was running into this issue and discovered that the problem was a new dependency that I added. In my case it was assets_audio_player: ^3.0.3+1, but of course it could be any dependency. Deleting it immediately fixed my problem.

Upvotes: 19

MuscleNerd
MuscleNerd

Reputation: 51

run flutter upgrade in an external admin cmd console

Upvotes: 2

Related Questions