Home: Access denied for restore/update packages

Created on 18 Dec 2017  路  24Comments  路  Source: NuGet/Home

I am using Windows 10 with Visual Studio 2017 Community. I am creating Xamarin project and right after that I am updating NuGet packages, but I see this error - Access to the path c:users/username/.nuget/packages/* is denied. The Nuget creates read-only folders with no access for all Windows users to them and after that it has no access to these folders. I am using Visual Studio as admin. If restart Visual Studio I have access to these folder, but after that if I try to update some or all packages again I get same error.

Restore External Bug

Most helpful comment

Any updates on this issue ?
I cleared NuGet cache, and now I am having this problem.

All 24 comments

@vladi160 NuGet doesn't specifically set permissions on these files, it uses the defaults.

I suggest changing the permissions on your .nuget folder manually to ensure that you can also access these files from a non-admin process.

@vladi160 Please let us know if you are still blocked.

Hi, .nuget folder is with full permissions. This problem is not for all package folders. For the example when I test now is this folder Error: Access to the path 'C:\Users\username\.nuget\packages\xamarin.android.support.design\25.4.0.2' is denied.

Set the permission on your packages folder and try again.

This is still happening, was there an actual fix?

Having the same issue.

  • Running Visual Studio as administrator or not does not affect this problem.
  • Deleting the project and clone it from the remote again does not fix the problem.
  • Removing all NuGet packages results in another error: _Assets file project.assets.json not found. Run a NuGet package restore to generate this file_.
  • Removing or adding NuGet packages will give you the same "access denied" error, but with different package-names.
  • Same behaviour with dotnet restore as with Update-Package

I'm having a similar issue. Running VS as admin or running dotnet restore in my console as an admin does not overcome this error message saying that I've been denied access.

Any updates on this issue ?
I cleared NuGet cache, and now I am having this problem.

I have cleared the nuget cache. After that I ran dotnet restore.

I received below error:

C:\Program Filesdotnet\sdk\2.1.403\NuGet.targets(114,5): error : Access to the path 'System.Diagnostics.DiagnosticSource.dll' is denied. [E:\XXXX\My project.sln]

Looks like clearing nuget cache causing issue.
Please guide.

I have cleared the nuget cache. After that I ran dotnet restore.

I received below error:

C:\Program Filesdotnet\sdk\2.1.403\NuGet.targets(114,5): error : Access to the path 'System.Diagnostics.DiagnosticSource.dll' is denied. [E:\XXXX\My project.sln]

Looks like clearing nuget cache causing issue.
Please guide.

Deleted mentioned file(s) and folder as mentioned in the question description.

I've encountered similar issues with VS 2015 but was able to delete my AppData\Roaming\NuGet\NuGet.config or delete <my user profile path>.nuget\packages to fix it.

I've just faced a similar issue on linux (Ubuntu) and felt like this would be the best place to record the resolution:

I run 64-bit Ubuntu, and I think I installed dotnet with sudo (for some reason).
As such, when NuGet packages were downloaded to /home/{me}/.nuget/{etc.}, the folders inside were owned by root.
Because of this, when I attempted to download those NuGet packages (actually via Paket, a NuGet client alternative), it failed due to access issues.

To resolve, this I cd'd my way to the .nuget folder inside home, and did this bad boy: sudo chown -R $USER:$USER .

Then, I got past that hurdle.

I had this issue and fixed it by setting $USER before running dotnet new <proj type>. Also make sure your user has permission for files in the the ~/.nuget/ directory.

Same issue. I had 3 instances of Visual Studio 2017 open. It appears one of them may have acquired some kind of lock on a resource? Anyway, after closing down the other two instances, the restore worked.

I've just faced a similar issue on linux (Ubuntu) and felt like this would be the best place to record the resolution:

I run 64-bit Ubuntu, and I think I installed dotnet with sudo (for some reason).
As such, when NuGet packages were downloaded to /home/{me}/.nuget/{etc.}, the folders inside were owned by root.
Because of this, when I attempted to download those NuGet packages (actually via Paket, a NuGet client alternative), it failed due to access issues.

To resolve, this I cd'd my way to the .nuget folder inside home, and did this bad boy: sudo chown -R $USER:$USER .

Then, I got past that hurdle.

Thank you. I had this issue on a fresh install of visual studio 19 on MacOS Mojave(10.14.6). I used sudo chown -R myUsername .

Glad it was helpful @jalaniz1 !

I am also facing the same issue... in VS2015

I also faced the same issue. The issue was that dll at the given Nuget/packages* location was read-only. The fix was to make the dll non read-only in file properties.
Thanks.

So my case was...
VS2015 Update-3, had solution folder .nuget which had our own nuget repositories referred.

This .nuget solution folder was creating trouble.
I deleted that .nuget folder and added those local nuget repository directly to the Visual Studio.

After that I am able to install and update packages.

Issue was with solution .nuget folder.

I did a

dotnet nuget locals all -c

and now I can neither access nor delete the package subdirectory. :sob:
I am on Windows 8.1. Does anybody have an advice? I should add that I do have local admin rights on my machine. I can't even delete the folder from an admin cmd.

Never mind. Problem solved. I forgot about the good old Windows rule:

classic

@svdHero - What is that image from?

@ronwarner IT Crowd - first episode, I think.

Yes. Brilliant TV series. At least the first two seasons.

So my case was...
VS2015 Update-3, had solution folder .nuget which had our own nuget repositories referred.

This .nuget solution folder was creating trouble.
I deleted that .nuget folder and added those local nuget repository directly to the Visual Studio.

After that I am able to install and update packages.

Issue was with solution .nuget folder.

where is that folder?

Was this page helpful?
0 / 5 - 0 ratings