Pub failed to rename directory because access was denied - flutter

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.

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

"flutter pub get" A required privilege is not held by the client

I keep getting this error on Android Studio flutter project, although flutter doctor command shows no issues!
Cannot create link, path = 'C:\Users\UserName\AppData\Local\Pub\Cache\_temp\dir90f89940\ios\Classes\FLTFirebaseAuthPlugin.m'
(OS Error: A required privilege is not held by the client.
, errno = 1314)
pub get failed (66; , errno = 1314))
I tried with pub upgrade which seams to get dependencies correctly and start updating them, but I didn't know why pub get give this error.
Update
A workaround seems to be running Android Studio as administrator!
I have switched ON developer mode in Windows settings (Settings -> Update & security -> For developers) . It worked for me.
Like so:
I'm using vscode I just opened it as administrator and everything works fine.
If you are using Android Studio:
open Android Studio with "Run as administrator"
Just run your PowerShell in administrator mode
the
cd to your project and run
flutter pub get
I wanted to add this solution because when you have accounts managed by your company this is a common problem.
Just go to your quick acces in Start then:
Right Click > More > Open File Location
When the Explorer Opens Right Click again on the AS Icon (quick access), then:
Properties > Advanced ... > Run as Administrator
So you can run always by default as Administrator.
Regards.-
Just run your IDE whether VS Code or Android Studio as Administrator . It solves the issue
Other temporary solution is that making pub cache and then trying flutter pub get.
https://spikez.tistory.com/439
Solution :
1.  flutter pub get
 
 ==> error will be occurred.
[your flutter sdk folder]\flutter.pub-cache_temp\ dir7d36fb45\macos\Classes\FlutterBluePlugin.h' (OS Error: 지정된 파일을 찾을 수 없습니다. , errno = 2)
copy dir7d36fb45  to [your flutter sdk folder]\flutter.pub-cache\hosted\pub.dartlang.org 
change name dir7d36fb45 to flutter_blue-0.8.0
cd flutter_blue-0.8.0 (created by you)
create pubspec.yaml in flutter_blue-0.8.0 folder
fill below content in pubspec.yaml
now you have done preparing flutter_blue cache  :)
lets do, flutter pub get
maybe it will be work.
I know it is a temporary solution. but I believe it will help you understand how to work pub get..
 
If you need new pubspec.yaml ,
you can find out in here  : https://github.com/pauldemarco/flutter_blue/blob/master/pubspec.yaml

I add audioplayers 0.19.1 package from pub dev but when I run pub get, I face the Error , Cannot create link, I don't know what happened

Here is the Error I face
Cannot create link, path = 'C:\flutter\.pub cache\_temp\dir627f91b4\ios\Classes\AudioplayersPlugin.h' (OS Error: A required privilege is not held by the client.
, errno = 1314)
pub get failed (66; , errno = 1314))
This problem happens for permission issue. So you just need to run Command Prompt in administrator and then type
cd folderpath
after that you can run pub get
pub get
This will be fix your problem
running "vs code" (or what ever the IDE you use). run as admin solved my problem. and do what you always do in the terminal run command: flutter pub get
Audioplayers have been depricated use just_audio

Issue with Pub Get via dart extension in VSCode

I've got a problem where running pub get via the VSCode dart extension doesn't actually get the packages. It doesn't return an error but if I attempt to build my project, it will just continuously tell me my pubspec lock has updated since I last ran pub get.
Running flutter pub get via terminal solves the issue straight way.
Has anyone else experienced this with VSCode?
You can
delete pubspec.lock
then
flutter clean
Reinstall Extensions

pub get failed (66; Could not find a file named "pubspec.yaml" in "C:\Windows\System32"

fatal: not a git repository (or any of the parent directories): .git Could not find a file named "pubspec.yaml" in "C:\Windows\System32". pub get failed (66; Could not find a file named "pubspec.yaml" in "C:\Windows\System32".)
hi everyone
I got this error message every time when I tried to create a flutter project by an android studio or by cmd
I checked flutter doctor command and appear no problems about flutter installation
so any advice about this problem?
[error message when I used android studio 1
flutter doctor message
You can try below steps:
First, you reboot(restart) your PC.
Before opening anything, you delete your flutter folder.
Unzipped a new flutter installation into the same directory.
Inside your project directory You run flutter packages get
Then open the IDE and everything will be working.
Refer flutter issue for more information.

Unable to create flutter project

When running flutter create followed by project name, I receive this error:
Error: Error when reading '../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No such file or directory
Running "flutter pub get" in pics...
pub get failed (254; Error: Error when reading
'../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No
such file or directory)
I'm trying to create a new flutter project in xcode. How would I fix this?
'../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No
such file or directory
It seems like there may be files missing from your Flutter SDK. There should be a file in the Flutter SDK at bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot but this error suggests it's missing.
The easiest fix may be to delete the bin/cache folder which will cause Flutter to re-download the Dart SDK and other components when you next run flutter. This may take a little while depending on your connection, but is the simplest way to ensure the cache folder is complete. I would suggest closing all IDEs/editors when doing this.
I have same issue but the problem was windows defender at real time detection so the solution was to switch off it then create a project...