Description
dotnet CLI first-run experience fails intermittently on Linux with:
System.IO.IOException: The file '/tmp/.dotnet/shm/session1/NuGet-Migrations' already exists.
at System.IO.SharedMemoryHelpers.CreateOrOpenFile(String sharedMemoryFilePath, SharedMemoryId id, Boolean createIfNotExist, Boolean& createdFile)
at System.IO.SharedMemoryProcessDataHeader`1.CreateOrOpen(...)
at System.Threading.NamedMutexProcessDataBase.CreateOrOpen(...)
at System.Threading.WaitSubsystem.NamedMutex.CreateNamedMutex(...)
at System.Threading.Mutex.CreateMutexCore(...)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
at NuGet.Common.Migrations.MigrationRunner.Run(...)
at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime)
This is blocking the VMR official build (dotnet-unified-build definition 1330) on main. Observed in:
- Build 20260316.1 —
ValidateInstallers_Linux_x64 job, DebScenarioTest(repo: "mcr.microsoft.com/dotnet/runtime-deps", tag: "10.0-noble")
The VerifyConsoleTemplateComplex(CSharp) scenario test runs dotnet new console inside a Docker container. A prior dotnet invocation in the same container created the shared memory file at /tmp/.dotnet/shm/session1/NuGet-Migrations. The second invocation's CreateOrOpenFile throws IOException instead of opening the existing file.
Expected behavior
SharedMemoryHelpers.CreateOrOpenFile should handle the case where the shared memory file already exists from a previous process, either by opening it or by recreating it.
Actual behavior
Throws System.IO.IOException: The file ... already exists and the dotnet command fails with exit code 1.
Relation to prior issue
dotnet/runtime#80619 tracked a similar NuGet-Migrations mutex failure on Windows (The system cannot open the device or file specified) in .NET 7/8 timeframe. That issue was fixed and closed in Aug 2023. This appears to be a different codepath — the new SharedMemoryProcessDataHeader / SharedMemoryHelpers implementation on Linux.
Description
dotnetCLI first-run experience fails intermittently on Linux with:This is blocking the VMR official build (
dotnet-unified-builddefinition 1330) onmain. Observed in:ValidateInstallers_Linux_x64job,DebScenarioTest(repo: "mcr.microsoft.com/dotnet/runtime-deps", tag: "10.0-noble")The
VerifyConsoleTemplateComplex(CSharp)scenario test runsdotnet new consoleinside a Docker container. A priordotnetinvocation in the same container created the shared memory file at/tmp/.dotnet/shm/session1/NuGet-Migrations. The second invocation'sCreateOrOpenFilethrowsIOExceptioninstead of opening the existing file.Expected behavior
SharedMemoryHelpers.CreateOrOpenFileshould handle the case where the shared memory file already exists from a previous process, either by opening it or by recreating it.Actual behavior
Throws
System.IO.IOException: The file ... already existsand thedotnetcommand fails with exit code 1.Relation to prior issue
dotnet/runtime#80619 tracked a similar
NuGet-Migrationsmutex failure on Windows (The system cannot open the device or file specified) in .NET 7/8 timeframe. That issue was fixed and closed in Aug 2023. This appears to be a different codepath — the newSharedMemoryProcessDataHeader/SharedMemoryHelpersimplementation on Linux.