NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Attempting to build on Ubuntu Docker Container -- SMB Share Nuget Cache -- Results in access denied for single package #13837

Closed sykesbPragmatics closed 3 weeks ago

sykesbPragmatics commented 1 month ago

NuGet Product Used

dotnet.exe

Product Version

dotnet core 8

Worked before?

No response

Impact

It bothers me. A fix would be nice

Repro Steps & Context

Describe the bug No matter what I do I always get an error while trying to restore nuget on a single package file. A ton of other packages work successfully but this one always fails no matter what. If I run without the smb cache everything works fine but obviously much slower since I don't have any cache of files.

The build agent is a docker container on Ubuntu and I'm attaching an smb file share to /mnt/build-agent-share so that I can get nuget caching. I cannot mount a local folder to the docker image as I do not own the VM, its a shared "ephemeral" build agent designed to be killed off after every run.

I have attempted deleting the folder entirely and starting over, attempting to own the folder once its mounted.... Anyone have any ideas?

Verbose Logs

simple dotnet build:

/usr/lib/dotnet/sdk/8.0.108/NuGet.targets(156,5): error : Access to the path '/mnt/build-agent-share/nugetcache/microsoft.netcore.app.host.linux-x64/8.0.8/Microsoft.NETCore.App.Host.linux-x64.nuspec' is denied. [/opt/agent/_work/1/s/Src/Project.csproj] /usr/lib/dotnet/sdk/8.0.108/NuGet.targets(156,5): error :   Operation not permitted [/opt/agent/_work/1/s/Src/Project.csproj]

The file is definitely created, but seems to be failing when its trying to unzip

Alternate log when attempting to just do dotnet restore
 1>/usr/lib/dotnet/sdk/8.0.108/NuGet.targets(156,5): error : Access to the path '/mnt/build-agent-share/nugetcache/microsoft.netcore.app.host.linux-x64/8.0.8/Microsoft.NETCore.App.Host.linux-x64.nuspec' is denied. [/opt/agent/_work/1/s/Project.csproj] /usr/lib/dotnet/sdk/8.0.108/NuGet.targets(156,5): error :   Operation not permitted [/opt/agent/_work/1/s/Project.csproj] Assembly loaded during TaskRun (NuGet.Build.Tasks.RestoreTask): System.Diagnostics.StackTrace, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (location: /usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/System.Diagnostics.StackTrace.dll, MVID: 4061053c-27f4-4307-bc08-8a769a70c3f3, AppDomain: [Default]) System.UnauthorizedAccessException: Access to the path '/mnt/build-agent-share/nugetcache/microsoft.netcore.app.host.linux-x64/8.0.8/Microsoft.NETCore.App.Host.linux-x64.nuspec' is denied. ---> System.IO.IOException: Operation not permitted --- End of inner exception stack trace --- at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) at Interop.CheckIo(Int64 result, String path, Boolean isDirError) at System.IO.FileStatus.SetAccessOrWriteTimeCore(SafeFileHandle handle, String path, DateTimeOffset time, Boolean isAccessTime, Boolean checkCreationTime, Boolean asDirectory) at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc) at NuGet.Packaging.ZipArchiveExtensions.Testable.UpdateFileTimeEntry(String fileFullPath, DateTime dateTime) at NuGet.Packaging.ZipArchiveExtensions.Testable.UpdateFileTimeFromEntry(ZipArchiveEntry entry, String fileFullPath, ILogger logger) at NuGet.Packaging.ZipArchiveExtensions.UpdateFileTimeFromEntry(ZipArchiveEntry entry, String fileFullPath, ILogger logger) at NuGet.Packaging.PackageArchiveReader.CopyFiles(String destination, IEnumerable1 packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken token)
at NuGet.Packaging.PackageReaderBase.CopyFilesAsync(String destination, IEnumerable1 packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken cancellationToken) at NuGet.Packaging.PackageExtractor.<>c__DisplayClass5_2.<<InstallFromSourceAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func2 action, CancellationToken token)
at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func2 action, CancellationToken token) at NuGet.Packaging.PackageExtractor.InstallFromSourceAsync(PackageIdentity packageIdentity, IPackageDownloader packageDownloader, VersionFolderPathResolver versionFolderPathResolver, PackageExtractionContext packageExtractionContext, CancellationToken token, Guid parentId) at NuGet.Commands.ProjectRestoreCommand.InstallPackageAsync(RemoteMatch installItem, NuGetv3LocalRepository userPackageFolder, PackageExtractionContext packageExtractionContext, CancellationToken token) at NuGet.Commands.ProjectRestoreCommand.<>c__DisplayClass15_1.<<InstallPackagesAsync>b__4>d.MoveNext() --- End of stack trace from previous location --- at NuGet.Commands.ProjectRestoreCommand.InstallPackagesAsync(HashSet1 uniquePackages, IEnumerable1 graphs, IList1 downloadDependencyInformations, NuGetv3LocalRepository userPackageFolder, CancellationToken token)
at NuGet.Commands.ProjectRestoreCommand.TryRestoreAsync(LibraryRange projectRange, IEnumerable1 frameworkRuntimePairs, NuGetv3LocalRepository userPackageFolder, IReadOnlyList1 fallbackPackageFolders, RemoteDependencyWalker remoteWalker, RemoteWalkContext context, Boolean forceRuntimeGraphCreation, CancellationToken token, TelemetryActivity telemetryActivity, String telemetryPrefix)
at NuGet.Commands.RestoreCommand.ExecuteRestoreAsync(NuGetv3LocalRepository userPackageFolder, IReadOnlyList1 fallbackPackageFolders, RemoteWalkContext context, CancellationToken token, TelemetryActivity telemetryActivity) at NuGet.Commands.RestoreCommand.ExecuteAsync(CancellationToken token) at NuGet.Commands.RestoreRunner.ExecuteAsync(RestoreSummaryRequest summaryRequest, CancellationToken token) at NuGet.Commands.RestoreRunner.ExecuteAndCommitAsync(RestoreSummaryRequest summaryRequest, IRestoreProgressReporter progressReporter, CancellationToken token) at NuGet.Commands.RestoreRunner.CompleteTaskAsync(List1 restoreTasks)
at NuGet.Commands.RestoreRunner.RunAsync(IEnumerable`1 restoreRequests, RestoreArgs restoreArgs, CancellationToken token)
at NuGet.Commands.RestoreRunner.RunAsync(RestoreArgs restoreContext, CancellationToken token)
at NuGet.Build.Tasks.BuildTasksUtility.RestoreAsync(DependencyGraphSpec dependencyGraphSpec, Boolean interactive, Boolean recursive, Boolean noCache, Boolean ignoreFailedSources, Boolean disableParallel, Boolean force, Boolean forceEvaluate, Boolean hideWarningsAndErrors, Boolean restorePC, Boolean cleanupAssetsForUnsupportedProjects, ILogger log, CancellationToken cancellationToken)
at NuGet.Build.Tasks.RestoreTask.ExecuteAsync(ILogger log)
Done executing task "RestoreTask" -- FAILED.
1>Done building target "Restore" in project "Project.csproj" -- FAILED.
1>Done Building Project "/opt/agent/_work/1/s/Project.csproj" (Restore target(s)) -- FAILED.

`
jeffkl commented 3 weeks ago

NuGet calls standard APIs in .NET to read and write files. I'm going to close this for now since its not really NuGet specific other than this one folder happens to be NuGet's global packages cache and it cannot write to it.

I'm not sure who would be the right person to ask about this, it seems like an easy task to solve by just granting write permissions. But this set up sounds a little more complicated than normal. I hope you get this figured out.

sykesbPragmatics commented 3 weeks ago

In case someone finds this in the future, I basically gave up. This scenario occurred on a VM in Azure against an SMB share. I ended up doing it as an alternative using a NFS share, which seemed to work. NO CLUE why the SMB share was blocking/locking/failing.