dotnet 错误:无法获取“/tmp/NuGetScratch/lock/”上的锁定文件访问权限

Lim*_*mup 9 fedora .net-core

重现步骤

dotnet 构建或 dotnet 运行

预期行为

运行或构建应用程序

实际行为

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'
Run Code Online (Sandbox Code Playgroud)

环境数据

点网--信息

.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
Run Code Online (Sandbox Code Playgroud)

观测值

尝试在 dotnet Restore 中进行修复,但我收到了相同的错误。

dotnet sdk 2.0 没有这个问题。

Fen*_*nix 15

就我而言,问题是由“锁定文件”的所有权(在 Linux 中)引起的。我在我的用户下运行dotnet build(没有 sudo),但我的项目是使用sudo.

选项 A) 再次使用 sudo

sudo dotnet build
Run Code Online (Sandbox Code Playgroud)

选项 B) 更改 /tmp/NuGetScratch/lock/ 所有权:

sudo chown -R <user>:<user> /tmp/NuGetScratch/
Run Code Online (Sandbox Code Playgroud)

然后,用户dotnet build无需 sudo 即可运行。

  • 如果您之前在错误的用户下运行过“dotnet build”,那么“sudo dotnet clean”肯定会有所帮助 (2认同)

Lim*_*mup 2

我用下面的命令修复了这个错误:

export TMPDIR=/tmp/NuGetScratch/
mkdir -p ${TMPDIR}
Run Code Online (Sandbox Code Playgroud)

但是,我收到了其他错误,我打开了其他问题帖子:帖子