Pub failed to rename directory because access was denied

Viewed 902

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.

4 Answers

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

Related