sdk icon indicating copy to clipboard operation
sdk copied to clipboard

"dotnet" commands have permission issues

Open mrlife opened this issue 8 years ago • 29 comments

Steps to reproduce

run dotnet clean, dotnet restore, dotnet build, or dotnet publish

Expected behavior

The command should complete without error

Actual behavior

Here is the error:

$ dotnet clean

Configuring...

A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once. Decompressing 100% 6734 ms System.AggregateException: One or more errors occurred. (One or more errors occurred. (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.entityframeworkcore.tools/2.1.1/microsoft.entityframeworkcore.tools.nuspec' is denied.))

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json): Version: 2.1.302 Commit: 9048955601

Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.13-x64 Base Path: /usr/local/share/dotnet/sdk/2.1.302/

Host (useful for support): Version: 2.1.2 Commit: 811c3ce6c0

.NET Core SDKs installed: 2.1.4 [/usr/local/share/dotnet/sdk] 2.1.300-preview2-008533 [/usr/local/share/dotnet/sdk] 2.1.300 [/usr/local/share/dotnet/sdk] 2.1.301 [/usr/local/share/dotnet/sdk] 2.1.302 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0-preview1-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.0-preview2-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0-preview1-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.0-preview2-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0-preview1-26216-03 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0-preview2-26406-04 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

mrlife avatar Aug 09 '18 19:08 mrlife

Looks like deleting the "NuGetFallbackFolder" fixed the issue. Any idea what the problem was?

mrlife avatar Aug 09 '18 19:08 mrlife

how did you install SDK via tar.gz or apt-get? install via tar.gz might have this problem when you did not run it with sudo when the location is a sudo location.

wli3 avatar Aug 09 '18 21:08 wli3

I used the macOS "Installer" from: https://www.microsoft.com/net/download/dotnet-core/2.1. I think it had a .pkg extension.

mrlife avatar Aug 10 '18 01:08 mrlife

I'm facing the same error on ubuntu updating to apt-git. I renamed the folder to NuGetfallbackFolder.bak, and the SDK still complains about it but allows me to continue

cuevaskoch avatar Aug 13 '18 20:08 cuevaskoch

@jrkoch @mrlife it should be some permission mismatch. The end goal is expand nugetfallbackfolder with correct permission. To fix it, you could run any dotnet command other than help/info with sudo. However, i am still investigating why this issue happens in the first place. 1. fallbackfolder should expand during installer with sudo. Did it get interrupted? 2. when it find no permission to expand, SDK should try to expand it under ~/.dotnet folder

wli3 avatar Aug 13 '18 21:08 wli3

Similar issue here, but on Windows

https://github.com/dotnet/cli/issues/9842

wli3 avatar Aug 15 '18 18:08 wli3

It didn’t get interrupted in my case. I am facing it on two Ubuntu installs, both running 18.04 upgraded from 17.10. And both had the dotnet 2.1 preview installed and have been kept up to date via the apt repositories. On Wed, Aug 15, 2018 at 11:14 AM William Li [email protected] wrote:

Similar issue here, but on Windows

dotnet/cli#9842 https://github.com/dotnet/cli/issues/9842

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/cli/issues/9807#issuecomment-413286418, or mute the thread https://github.com/notifications/unsubscribe-auth/AEbwK5pzvIpl3J_ysOYqfIIkqY6ScQ9Kks5uRGT9gaJpZM4V2Q2j .

cuevaskoch avatar Aug 15 '18 18:08 cuevaskoch

Responding to questions on other issue @livarcocc:

How is dotnet being installed? Msi? Zip?

Msi install

When prompted for admin permissions, are you allowing it?

In the installer? Yes.

The fallback folder should be expanded by the msi during installation. Something is either causing it not to happen or it is happening and we are failing to write the sentinel file that tells us it did happen.

Do you happen to have a DOTNET_SKIP_FIRST_RUN_EXPERIENCE environment variable set to true?

No, it is not set.

Tadimsky avatar Aug 15 '18 18:08 Tadimsky

Also happening on a brand new MacOS system, first time install of latest SDK (2.1.400). Any dotnet command results in:

-> % dotnet restore

Permission denied to modify the '/usr/local/share/dotnet/sdk/NuGetFallbackFolder' folder.

Here are some options to fix this error:
----------------------------------------
1. Re-run this command with elevated access.
2. Disabled the first run experience by setting the environment variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE to true.
3. Copy the .NET Core SDK to a non-protected location and use it from there.

The sdk was installed from the MacOS package installer on a fresh system.

I tried using a 'sudo dotnet' command but now I'm getting multiple exceptions:

-> % sudo dotnet tool

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Decompressing 100% 5130 ms
System.AggregateException: One or more errors occurred. (One or more errors occurred. (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.io.filesystem/4.0.1/ref/netstandard1.3/System.IO.FileSystem.dll' is denied.)) (One or more errors occurred. (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.reflection.extensions/4.0.1/lib/MonoAndroid10/_._' is denied.)) (One or more errors occurred. (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.reflection.emit.lightweight/4.3.0/system.reflection.emit.lightweight.nuspec' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (One or more errors occurred. (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.diagnostics.process/4.3.0/runtimes/win/lib/netstandard1.4/System.Diagnostics.Process.dll' is denied.)) (One or more errors occurred. (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.runtime.serialization.primitives/4.3.0/ref/netstandard1.0/ru/System.Runtime.Serialization.Primitives.xml' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (One or more errors occurred. (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.)) (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.io.filesystem/4.0.1/ref/netstandard1.3/System.IO.FileSystem.dll' is denied.) (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.reflection.extensions/4.0.1/lib/MonoAndroid10/_._' is denied.) (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.reflection.emit.lightweight/4.3.0/system.reflection.emit.lightweight.nuspec' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.diagnostics.process/4.3.0/runtimes/win/lib/netstandard1.4/System.Diagnostics.Process.dll' is denied.) (Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.runtime.serialization.primitives/4.3.0/ref/netstandard1.0/ru/System.Runtime.Serialization.Primitives.xml' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) (Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied.) ---> System.UnauthorizedAccessException: Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.io.filesystem/4.0.1/ref/netstandard1.3/System.IO.FileSystem.dll' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   --- End of inner exception stack trace ---
   at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
   at System.Linq.Parallel.SpoolingTask.SpoolForAll[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, TaskScheduler taskScheduler)
   at System.Linq.Parallel.MergeExecutor`1.Execute()
   at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
   at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
   at System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
   at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
   at System.Linq.Parallel.ListQueryResults`1.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
   at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
   at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
   at System.Linq.Parallel.ForAllOperator`1.RunSynchronously()
   at System.Linq.ParallelEnumerable.ForAll[TSource](ParallelQuery`1 source, Action`1 action)
   at Microsoft.DotNet.Archive.IndexedArchive.Extract(String compressedArchivePath, String outputDirectory, IProgress`1 progress)
   at Microsoft.DotNet.Configurer.NuGetPackagesArchiver.ExtractArchive(String archiveDestination)
   at Microsoft.DotNet.Configurer.NuGetCachePrimer.PrimeCache()
   at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
   at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, Boolean hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)
---> (Inner Exception #0) System.UnauthorizedAccessException: Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.io.filesystem/4.0.1/ref/netstandard1.3/System.IO.FileSystem.dll' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4283) System.UnauthorizedAccessException: Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.reflection.extensions/4.0.1/lib/MonoAndroid10/_._' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4284) System.UnauthorizedAccessException: Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.reflection.emit.lightweight/4.3.0/system.reflection.emit.lightweight.nuspec' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4285) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4286) System.UnauthorizedAccessException: Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.diagnostics.process/4.3.0/runtimes/win/lib/netstandard1.4/System.Diagnostics.Process.dll' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/cli#5) System.UnauthorizedAccessException: Access to the path '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/system.runtime.serialization.primitives/4.3.0/ref/netstandard1.0/ru/System.Runtime.Serialization.Primitives.xml' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/cli#6) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/cli#7) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/cli#8) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4287) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4288) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

---> (Inner Exception dotnet/sdk#4289) System.UnauthorizedAccessException: Access to the path '/tmp/724440ba-4e14-46a4-b8ce-3f77e1adfd35' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.DotNet.Archive.ThreadLocalZipArchive.<>c__DisplayClass2_0.<.ctor>b__0()
   at System.Threading.ThreadLocal`1.GetValueSlow()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractSource.CopyToStream(Stream destinationStream)
   at Microsoft.DotNet.Archive.IndexedArchive.ZipOperation.Execute()
   at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
   at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

jtsom avatar Aug 17 '18 12:08 jtsom

Well, turns out it looks like it was the install of Trend Micro Antivirus. I had the IT department uninstall it and the sudo tool command went through without a problem....

jtsom avatar Aug 17 '18 14:08 jtsom

If you follow the advice and run build as root using sudo once then your obj/bin folders will be owned by root and your normal build will fail.

Please fix this properly, building should never!!! ever require admin rights, this is so very, very, very wrong.

This cache should be in a location and with permissions that non sudo users can access.

trampster avatar Oct 26 '18 10:10 trampster

I faced the similar issue on Windows 7 laptop where the dotnet commands were running successfully. This problem appeared suddenly. When I tried to run the same command in Administrator mode as described, packages cache got updated. So package cache management is the culprit?

Configuring...

A command is running to populate your local package cache to improve restore spe ed and enable offline access. This command takes up to one minute to complete an d only runs once. Decompressing 100% 40101 ms Expanding 100% 135531 ms

The dotnet.exe is executing well once the cache population is completed.

tmasabari avatar Nov 19 '18 23:11 tmasabari

I received this error because I set my Environment to production (to try fix another issue). The below fixed it for me

On Linux export ASPNETCORE_ENVIRONMENT=Development

MacOS and Windows see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.1

bitcoinbrisbane avatar Nov 25 '18 06:11 bitcoinbrisbane

I'm facing the same error on ubuntu updating to apt-git. I renamed the folder to NuGetfallbackFolder.bak, and the SDK still complains about it but allows me to continue

This worked for me, the problem started after the update to dotnet core 2.2. I'm using Windows 10.

Imartinn avatar Dec 18 '18 11:12 Imartinn

I am too facing the same error. I have a newly configured ubuntu machine and after running:

~/code/c#/repos$ dotnet new console --output mvvm

and

~/code/c#/repos/mvvm$ dotnet restore

I get the following output error in both cases:

Permission denied to modify the '/usr/share/dotnet/sdk/NuGetFallbackFolder' folder. Here are some options to fix this error: ---------------------------------------- 1. Re-run this command with elevated access. 2. Disabled the first run experience by setting the environment variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE to true. 3. Copy the .NET Core SDK to a non-protected location and use it from there.

Here is my kernel version: Linux 4.15.0-42-generic dotnet/sdk#4317-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Here is the dotnet info:

~$ dotnet --info .NET Core SDK (reflecting any global.json): Version: 2.2.101 Commit: 236713b0b7

Runtime Environment: OS Name: ubuntu OS Version: 18.04 OS Platform: Linux RID: ubuntu.18.04-x64 Base Path: /usr/share/dotnet/sdk/2.2.101/

Host (useful for support): Version: 2.2.0 Commit: 1249f08fed

.NET Core SDKs installed: 2.2.101 [/usr/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

TrevorFradsham avatar Dec 24 '18 12:12 TrevorFradsham

I have been able to resolve my error by deleting the folder

/usr/share/dotnet/sdk/NuGetFallbackFolder

then completely uninstalling all dotnet components

dotnet-host dotnet-hostfxr-2.2 dotnet-runtime-2.2 dotnet-runtime-deps-2.2 dotnet-sdk-2.2

and reinstalling the dotnet-sdk2.2. Not really the way to fix the problem but it worked for me.

TrevorFradsham avatar Dec 24 '18 17:12 TrevorFradsham

I experience this issue on Linux Ubuntu 18.04.1 LTS. dotnet was installed with apt-get according to the instructions. When I run dotnet run in a project, I get the following error, but it doesn't prevent for the application to start:

:~/Projects/ScApp$ dotnet run

Permission denied to modify the '/usr/share/dotnet/sdk/NuGetFallbackFolder' folder.

Here are some options to fix this error:
----------------------------------------
1. Re-run this command with elevated access.
2. Disabled the first run experience by setting the environment variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE to true.
3. Copy the .NET Core SDK to a non-protected location and use it from there.

k-rus avatar Jan 24 '19 08:01 k-rus

Same issue on Windows10 with .NET Core 2.2.104. I deleted the NuGetFallbackFolder then went to Windows Add/Remove Programs and clicked repair it. Well, it somehow is repaired. I checked the C:\Program Files\dotnet\sdk and the NuGetFallbackFolder is back with no error on each run now.

hleng1 avatar Feb 16 '19 11:02 hleng1

Same issue for me, this happened to me right after I added the "Desktop environment for C++" workload to my VS2017 install. Maybe that messed with some permissions for that folder or it's ownership?

In my case I uninstalled all Core entries in Add/Remove, and then reinstalled from scratch, works fine now.

roa-nyx avatar Apr 17 '19 17:04 roa-nyx

I started having this issue on Win10 after updating to .NET core 2.2.203 from a previous 2.2 install (I'm not sure which but I think it was 2.2.104). I installed the SDK via the installer found on http://dot.net

To make the error go away I ran powershell as admin, killed all .NET process, VS Code, etc, and ran a dotnet restore in the source directory. After it completed I was able to go back into VS Code and non-admin powershell terminals and build without error.

tonyranieri avatar Apr 23 '19 15:04 tonyranieri