首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法快照- exec :不能拒绝exec "/snap/dotnet-sdk/152/snap/command-chain/snapcraft-runner":权限

无法快照- exec :不能拒绝exec "/snap/dotnet-sdk/152/snap/command-chain/snapcraft-runner":权限
EN

Stack Overflow用户
提问于 2022-01-26 16:32:30
回答 2查看 2.1K关注 0票数 4

安装snap后不能执行dotnet命令

我按照下面的说明安装了.NET 6.0预览。

安装后,当我尝试执行dotnet命令时,会收到以下错误消息:

无法执行- exec :不能执行"/snap/dotnet-sdk/152/snap/command-chain/snapcraft-runner":权限,这是因为目录/snap/dotnet/152/snap只能通过根用户访问,并且是一个挂载的文件系统,因此无法对其进行chmod。

我正在使用一个新的Ubuntu20.04安装,所以不应该有任何其他冲突。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-01-31 19:24:19

这似乎是snap别名的问题。只需取消快照和符号链接二进制就行了。

代码语言:javascript
复制
sudo snap unalias dotnet
sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet

然后,您应该能够在没有root权限的情况下调用dotnet --list-sdks

票数 8
EN

Stack Overflow用户

发布于 2022-01-26 16:32:30

代码语言:javascript
复制
# Install the .NET 6 SDK as a snap package.
# The snap package will automatically be mounted.
snap install dotnet-sdk --channel=6.0/beta --classic

# Try running the snap command. If this works, you do not have to
# apply the workaround. If this fails, continue.
dotnet-sdk.dotnet --version

# To find out where the snap package has been mounted,
# list all block devices and look for /snap/dotnet-sdk/
# in the MOUNTPOINT column. Remember the name of the loop
# device.
lsblk

# To get the actual path of the snap package file, run
# The path in the BACK-FILE column points to the snap package.
losetup --list

# Replace XXX with the number of your snap.
# find the /var/lib/snapd/snaps/dotnet-sdk_XXX.snap in the list
# Create a folder where we're extracting the snap package into.
mkdir dotnet-snap-fix
cd dotnet-snap-fix

# Extract the snap package into this directory.
# Add the correct BACK-FILE path to your snap package here.
# Replace XXX or the whole path with the BACK-FILE displayed by
# the losetup command above.
sudo unsquashfs /var/lib/snapd/snaps/dotnet-sdk_XXX.snap

# Change the permissions of the snap folder containing the runner
# to be readable and executable. This will fix the permission problem.
sudo chmod -R +rx ./squashfs-root/snap/

# Create a new snap package with the changed permissions.
# Make sure to use the same file name as in the BACK-FILE path.
# Replace XXX or the whole file name with the file name of the
# BACK-FILE path displayed by the losetup command above.
sudo mksquashfs ./squashfs-root/ dotnet-sdk_XXX.snap -comp xz -all-root

# Overwrite the old snap package with our new one.
# Make sure the file name is correct (same as in BACK-FILE).
sudo mv ./dotnet-sdk_XXX.snap /var/lib/snapd/snaps/

# Finally reboot your machine so the changes are detected.
sudo reboot

# Do not use snap disable / snap enable, they will replace the
# fixed snap package with the broken one again.
# After the reboot, the dotnet-sdk.dotnet command will work without sudo.
dotnet-sdk.dotnet

参考解决方案:https://github.com/dotnet/core/issues/4446#issuecomment-605629427

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70866937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档