dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.93k stars 4.9k forks source link

Cannot run dotnet command after installing 6.0 RC/preview using snap #4446

Closed nikonthethird closed 2 years ago

nikonthethird commented 4 years ago

The dotnet command cannot be executed after installing snap

General

I followed these instructions to install the .NET 5.0 preview using snap.

After installation, when I try to execute the dotnet command, I get the following error message:

cannot snap-exec: cannot exec "/snap/dotnet-sdk/67/snap/command-chain/snapcraft-runner": permission denied

This is because the directory /snap/dotnet-sdk/67/snap is only accessible by root and is a mounted file system, so it is not possible to chmod it.

I am using a fresh Ubuntu 18.04 install, so there should not be any other conflicts.

zigpot commented 2 years ago

This problem is fixed with version 7.0.0 in case anyone doesn't mind upgrading from 6.0

signor-mike commented 2 years ago

Had the same issue on Ubuntu. Removed snap and installed as apt. Works like a charm.

Replace 5.0 with desired version :)

sudo snap remove dotnet-sdk // if needed

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

sudo apt update

sudo apt install apt-transport-https

sudo apt-get install -y dotnet-sdk-5.0

And now dotnet --version gives me correct output, without sudo. Hallelujah https://stackoverflow.com/questions/69842779/permision-denied-for-dotnet

CapTearow commented 2 years ago

This is still an issue with snap and even on the 7.0 version on my side.

I use Solus so I don't have a native version on the repo so "install as apt" is not a solution on my side.

ksandaru commented 2 years ago

On my raspberry pi I installed .Net runtime and .Net core SDK. But, it only shows runtime and it can not find the SDK.

.NET Core SDKs installed: No SDKs were found.

.NET Core runtimes installed: Microsoft.NETCore.App 2.1.3 [/home/pi/dotnet/shared/Microsoft.NETCore.App]

(Used resource: https://snapcraft.io/install/dotnet-sdk/raspbian)

tznind commented 2 years ago

On my raspberry pi I installed .Net runtime and .Net core SDK. But, it only shows runtime and it can not find the SDK.

Try looking in /root/.dotnet. Thats where it installed for me. Furthermore I have to use sudo -s for permissions to run the dotnet command and it isn't configured to be on $PATH. All in all very suboptimal. This was using the dotnet_install.sh file.

ksandaru commented 2 years ago

@tznind I installed .NET SDK 3.1 on Raspberry pi 3b by referring Microsoft documentations. Then the runtime and SDK both were installed successfully.(Using Snap, the SDK couldn't be loaded) https://dotnet.microsoft.com/en-us/download/dotnet/3.

But, VS code shows the same error..(dotnet not found) sdk installed Capture1 1

tznind commented 2 years ago

Ah that looks like WinForms. I think you can't compile WinForms on linux. If you can compile a basic app e.g. dotnet new console then that might be the issue.

See https://stackoverflow.com/questions/60912058/how-to-install-and-use-winforms-in-vscode-on-linux

zezba9000 commented 2 years ago

@ksandaru You can only use WinForms on Linux if you use the Mono Runtime. Install mono & use that instead.

ksandaru commented 2 years ago

@ksandaru You can only use WinForms on Linux if you use the Mono Runtime. Install mono & use that instead.

I saw many articles that saying mono is deprecated..mono still works??

zezba9000 commented 2 years ago

@ksandaru Mono runtime is still under active development and is what powers C# apps to run on Android, iOS & WASM etc. The WinForms framework should even be considered depreciated on Windows.

If you're just trying to get legacy software to work on Linux with WinForms use Mono. If you're creating a new project don't use WinForms.

ksandaru commented 2 years ago

@ksandaru Mono runtime is still under active development and is what powers C# apps to run on Android, iOS & WASM etc. The WinForms framework should even be considered depreciated on Windows.

If you're just trying to get legacy software to work on Linux with WinForms use Mono. If you're creating a new project don't use WinForms.

Thank you..got it!