Skip to content

[Breaking change]: NuGet locks directory moved on Linux #56775

Closed

Description

@zivkan

Description

The directory NuGet uses to perform inter-process synchronization on Linux has moved, starting from the .NET 11.0.200 SDK. This means that if you have multiple dotnet processes running restore at the same time, but some are below this SDK version number, and other are higher than this SDK version number, the processes will not cooperatively share the global packages folder, or other NuGet files, and may cause failures or other undefined behavior.

The NUGET_SCRATCH environment variable can be used to force NuGet (any version) to use a specific directory, but leave out the trailing locks subdirectory.

Version

.NET 11 GA

Previous behavior

NuGet would create lock files in /tmp/NuGetScratch{username}/locks, unless overridden with the NUGET_SCRATCH environment variable.

New behavior

NuGet will create lock files in ~/.nuget/locks unless overriden with the NUGET_SCRATCH environment variable.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

On Windows and Mac, .NET's Path.GetTempPath() method returns a user-specific temp directory. On Linux, it returns the shared /tmp directory. Since the NuGetScratch{username}/locks path is deterministic, it allows malicious users on the system to block NuGet for the target account, forcing the target to use the NUGET_SCRATCH environment variable to be able to use NuGet and therefore the .NET SDK. Moving the lock files to within the user's HOME directory, reduces the risk that one user can block another on a shared computer.

Recommended action

Use the latest .NET SDK to build apps, even if the projects are targeting an earlier TargetFramework. Alternatively, use the NUGET_SCRATCH environment variable to force all versions of NuGet to use the same directory, until you're able to use .NET 11.0.200 and above everywhere.

Feature area

SDK

Affected APIs

No response

Activity

  1. added
    breaking-change
    on Nov 6, 2026
  2. added
    🗺️ mapQUEST
    on Nov 6, 2026
  3. removed
    🗺️ mapQUEST
    on Nov 6, 2026
  4. moved this from 🔖 Ready to 🏗 In progress in dotnet/docs November 2026 sprint projecton Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

breaking-change

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions