Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet error : Unable to obtain lock file access on '/tmp/NuGetScratch/lock/

Steps to reproduce

dotnet build or dotnet run

Expected behavior

Run or Build app

Actual Behavior

Getting ready...
The template "ASP.NET Core with Angular" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/limup/Documents/Projetos/Limup/salao/salao.csproj...
/usr/share/dotnet/sdk/3.1.101/NuGet.targets(123,5): error : Unable to obtain lock file access on '/tmp/NuGetScratch/lock/b19d3901039706ea82571abad7c98ec690508d4b' for operations on '/home/limup/Documents/Projetos/Limup/salao/obj/salao.csproj.nuget.cache'. This may mean that a different user or administator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file '/tmp/NuGetScratch/lock/b19d3901039706ea82571abad7c98ec690508d4b' will allow NuGet to continue. [/home/limup/Documents/Projetos/Limup/salao/salao.csproj]

Restore failed.
Post action failed.
Description: Restore NuGet packages required by this project.
Manual instructions: Run 'dotnet restore'

Environment Data

dotnet --info

.NET Core SDK (reflecting any global.json):
Version: 3.1.101
Commit: b377529961

Runtime Environment:
OS Name: fedora
OS Version: 31
OS Platform: Linux
RID: fedora.31-x64
Base Path: /usr/share/dotnet/sdk/3.1.101/

Host (useful for support):
Version: 3.1.1
Commit: a1388f194c

.NET Core SDKs installed:
3.1.101 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Obs

Tried Fixes put in dotnet restore, but I received the same error.

Did not have this problem with dotnet sdk 2.0.

like image 873
Limup Avatar asked Jan 25 '23 10:01

Limup


2 Answers

In my case, the problem was caused by ownership of the "lock file" (in Linux). I was running dotnet build under my user (without sudo) but my project was created using sudo.

Option A) Use sudo again

sudo dotnet build

Option B) Change /tmp/NuGetScratch/lock/ ownership:

sudo chown -R <user>:<user> /tmp/NuGetScratch/

Then, the user can run dotnet build without sudo.

like image 104
Fenix Avatar answered Mar 14 '23 23:03

Fenix


I fixed that bug with commands below:

export TMPDIR=/tmp/NuGetScratch/
mkdir -p ${TMPDIR}

but, I've been receive the other error and I opened other question post: Post

like image 38
Limup Avatar answered Mar 14 '23 22:03

Limup