-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interacting with NuGet fails on .NET 6.0.10 when running in docker with user #7868
Comments
Confirming that I am seeing this same issue, in our case in .NET Core SDK 3.1.424, using the official docker images. In addition to the commands listed in the original report, we also see this behavior with As of 3.1.424, when running a dotnet nuget command, an empty file at $HOME/.local/share/NuGet/Migrations/1 is being created. In the case of running as a user that does not have a mapped home directory, $HOME defaults to /, and when the dotnet process attempts to create $HOME/.local/share/NuGet/Migrations/1, the file/directory creation fails because only root has permissions to write to /. This shouldn't be a problem, because the DOTNET_CLI_HOME environment variable can be used to specify a different base directory for the dotnet files and directories, but this new Migrations directory/file operation does not appear to make appropriate use of this environment variable. SDK 3.1.423 and earlier do not share this behavior - the $HOME/.local/share/NuGet/Migrations/1 file does not appear to get created in these versions, and so this issue does not exist. |
I'm seeing the same issue as well, and I tried a workaround where I have our Docker container a fake HOME by specifying |
I also encountered this error. I had to force it to use the previous version of the image instead of the latest in the 6.0 family. So I used |
Confirming regression / new behaviour on SDK |
I have also encountered this today. @jsinger8290 You detailed the issue very well. I was able to resolve the issue by set 'XDG_CONFIG_HOME' as you would 'DOTNET_CLI_HOME.' This I think is the nuget code that is making use of the environment variable: |
Thanks, @jsinger8290, for the detailed analysis, and thanks @justindrocco for the link to the MigrationRunner, this was the missing piece of detail I was missing. Small correction to your comment: I was able to get a running version with the following command:
I support the opinion mentioned by @jsinger8290 for the MigrationRunner to make appropriate use of the DOTNET_CLI_HOME environment variable. |
Since the upgrade to Dotnet 6.0.10, there was a permission denied error (dotnet/core#7868). The version of dotnet is now also pinned in the Dockerfile.
Since the upgrade to Dotnet 6.0.10, there was a permission denied error (dotnet/core#7868). The version of dotnet is now also pinned in the Dockerfile.
The same issue affected us in a different way. We're using a docker agent for our jenkins pipeline, based on
We recently rebuilded the agent, and no need to specify that the pipeline worked last week. Setting the environment variable specified by @ravicini fixed the issue:
Once a fix has been pushed and the command uses the proper variable again, we'll rebuild the image and remove the variable. |
@MichaelSimons is this something you can help with? |
FYI the issue is still present on dotnet 7, using the image Image digest: sha256:f712881bafadf0e56250ece1da28ba2baedd03fb3dd49a67f209f9d0cf928e81 |
Same here, we use read-only containers in Kubernetes but we mount a writable |
We have a couple of folks that are still running in to this issue. @carlossanlop @MichaelSimons what is the correct way to get resolution on this? |
@lbussell - Can help out here? |
It seems like this should be handled in the NuGet.Client repo, I suggest opening an issue there - something like this looks similar: NuGet/Home#12712. The code in question seems to be here - https://github.com/NuGet/NuGet.Client/blob/4b618ca3c42fa0b678b28d17af2d815c1d26d28b/src/NuGet.Core/NuGet.Common/Migrations/MigrationRunner.cs#L84-L97 Typically for .NET Docker we recommend building as root and setting your final container as non-root (example). For tests however, I understand that this might cause issues. @MichaelSimons do you think we need a note somewhere in our documentation about this with a link to an issue (perhaps in this sample where we have a test target defined)? |
I guess that depends on how many people would find that documentation helpful (e.g. discover it when encountering the issue). Sometimes just having an issue is just as if not more discoverable for situations like this. Getting NuGet.Client to add support would be most useful. |
Description
We use the .NET SDK docker image to build our solution. Since the image
mcr.microsoft.com/dotnet/sdk:6.0
has been updated (10.10.2022 / .NET 6.0.10), we are encountering the following error when interacting with NuGet. This error happens only when we use a specific user (-u 1000:1000) to run the command.Steps to Reproduce:
sudo docker run -it -u 1000:1000 -e DOTNET_CLI_HOME=/tmp --rm --net=host --mount type=bind,source=/path/to/sln,target=/project mcr.microsoft.com/dotnet/sdk:6.0
cd /project
dotnet nuget list source
Error:
We tried to define a configuration to define the directory, as
/.local
does not exist, but we did not find any way to do this.Configuration
mcr.microsoft.com/dotnet/sdk:6.0
Regression?
It had worked with an already downloaded docker image. After deleting the image and pulling it again, this error started to occur.
Comment
Listing the NuGet sources was the first command we encountered failing, but neither do
dotnet restore
nordotnet build
.The text was updated successfully, but these errors were encountered: