-
Notifications
You must be signed in to change notification settings - Fork 258
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
[Bug]: The process cannot access the file 'NuGet.Config' because it is being used by another process. #11607
Comments
@mthalman - Were you able to reproduce this problem on the host machine? I am asking because of #9020 (comment). I see that the repository mentioned in the issue description doesn't have any
Can you please try to reproduce this issue after adding a I assume this issue may be somehow related to creation of
|
No
Yes, adding a NuGet.config file does make it work. I created the following NuGet.config file: <?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration> And I modified the Dockerfile to copy that NuGet.config file to the root of the container before running restore: COPY NuGet.config /
RUN dotnet restore complexapp/complexapp.csproj This allowed the restore to succeed.
Pruning images is being done on the host machine. The container doesn't even exist at that point. Once the container starts, that's when the user profile would exist. Again, it doesn't make sense to me why pruning images has an effect here other than causing more load to exist on the host machine when running NuGet/NuGet.Client#4338 certainly seems like a potential suspect considering it was introduced in 6.0.200. This issue shows a clear regression in this behavior between 6.0.102 and 6.0.200. |
I too have ran into this bug, and it's precisely as described here. During dotnet restore it tries to initialize the per-user config if it doesn't exist, and when running in parallel this results in multiple processes trying to WRITE to the file at once. Multiple readers is perfectly fine, and I'm guessing the internal code wasn't expecting writers as there's no synchronization around the creation of this resource. Generating the config yourself in advance (the one in %APPDATA%) avoids the problem because then it's all readers and no writers. This needs addressed, for sure. The only reason this has anything to do with containers is because developer machines are unlikely to have not ran nuget/dotnet restore at least once, so other than in containers you're not very likely to run into this situation. |
This issue was/will be resolved by: NuGet/NuGet.Client#4473 It will be available in the .NET SDK 6.0.300, VS/MSBuild 17.2, nuget.exe 6.2.0 when they're eventually released. In order to backport the fix .NET SDK 6.0.2xx, VS 17.2, nuget.exe 6.1.x, we need enough 👍 upvotes on the first comment to justify the management. |
It's a little depressing that upvotes are the criteria for making a change, vs assessing the impact. Eg this issue is affecting anyone using dotnet on github actions or Azure DevOps with default agents calling Also, I suspect that if you're just reverting the recent change, NuGet is still susceptible to this race condition (just less susceptible). This is proven both by the fact that #7503 was opened in 2018, and the source of the race condition is clearly described in #7503 by @bergbria. |
A number of factors go into the consideration, including impact. But my attempt last week to get early pre-approval got pushback 😞
Kind of. The other issue was specifically for Ignoring that, assuming that the creation of the Given all the other work we have, I think we have better things to work on than investigating theoretical bugs. |
I am also having this issue while building our multi-project solution in GitLab CI Shared Windows Runners. Building the solution in my personal machine is fine, but it fails at
Note that we are not using Docker to build our projects, and our projects are not designed to run in Docker. |
Could you loop in https://developercommunity.visualstudio.com/t/ubuntu-latest-fails-dotnet-tool-restore-with-proce/1673019 ?(still in "needs more info" even though steps were provided) |
I'm currently seeing this on an Azure Devops build agent on Linux when doing a dotnet restore, too. |
Can confirm it happens on ubuntu runners on GitHub Actions when dotnet restoring dotnet6 stuff |
Does anyone know if the fix for this is available in VS/MSBuild 17.2 Preview 3? Thanks! |
.NET SDK 6.0.300 has shipped now, so upgrading will resolve this issue. |
I still may have the issue with SDK v6.0.300:
|
Should solve occasional test failures (`dotnet tool restore` fails) See NuGet/Home#11607 (comment) (via NuGet/Home#7503 (comment))
Facing this problem yet. |
To anyone experiencing this issue, please be sure that parallel build invocations are using the same TEMP directory and APPDATA directories for each process. NuGet uses a cross-platform, cross-process syncronization system that assumes that if it can write to a particular file in TEMP, then it has exclusive access to a different file. If a build system changes TEMP to a different directory than other processes but does not change the APPDATA, then NuGet will be able to write to a file in TEMP and assume that it can write to the NuGet.config in the APPDATA location. |
I ran into this after upgrading to the |
NuGet Product Used
dotnet.exe
Product Version
6.0.200
Worked before?
6.0.102
Impact
I'm unable to use this version
Repro Steps & Context
When attempting to run
dotnet restore
on a multi-project solution, it results in the following error:This was encountered in the sample image tests for the dotnet/dotnet-docker repo after targeting the 6.0.200 SDK. This is a regression from 6.0.102.
The repro is consistent but requires a highly specific environment.
I've only been able to repro this in a Docker container, specifically a Windows Server version 20H2 container running on a Windows Server version 20H2 host machine. I cannot repro it with a different host version. For example, my Win 10 21H2 machine cannot repro it even though I'm targeting a 20H2 container.I've been able to repro this on a Windows Server version 20H2 and Windows Server 2022 host machine. Using 20H2 has produced the most consistent repro in our .NET Docker builds. It requires container process isolation, the default for Windows Server, which explains why it can't repro on my Win 10 21H2 machine because that can only use Hyper-V isolation (see Windows container version compatibility).This is very specific to 20H2 for some reason. The dotnet/dotnet-docker repo has the same tests that are run for other supported Windows versions and they all work.Also, cleaning of the Docker images is necessary between repro attempts. It doesn't make sense to me but, for whatever reason, not cleaning images after a previous attempt will cause the next attempt to succeed.
As for the repro solution, it's a multi-project solution consisting of 3 projects: a root project that references 2 child projects. If I remove one of the child projects, the issue doesn't repro.
Repro Steps
[smalldisk] Windows Server, version 20H2 with Containers
from the VM gallery which is Windows Server Core. I'm unsure if this would repro in a full Windows VM.complexapp.zip. This project originally comes from https://github.com/dotnet/dotnet-docker/tree/main/samples/complexapp.
cd complexapp
docker system prune -af
docker build .
. It should fail on thedotnet restore
step.Verbose Logs
The issue would not repro when using diagnostic verbosity (possibly timing related). But I was able to collect logs with detailed verbosity:
dotnet-restore.txt
The text was updated successfully, but these errors were encountered: