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

Viewed 14711

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.

9 Answers

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

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.

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

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.

run flutter upgrade in an external admin cmd console

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

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.

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

Related