iTranslated by AI
How to resolve 'dotnet: command not found' .NET Core error on M3 Mac
Installing the arm64 version of the SDK
I had the opportunity to open C# files on VSCode in an M3 Pro Mac environment, so I installed the .NET core SDK.
Since the environment is a Mac equipped with an Apple Silicon chip, I downloaded the arm64 version of the SDK.
% uname -m
arm64
After installing the SDK, I saw the following error message in the bottom right corner of the VSCode window.
.NET Core SDK not found: Error running dotnet --info: Error: Command failed: dotnet --info /bin/sh: dotnet: command not found /bin/sh: dotnet: command not found .NET Core debugging will not be enabled. Make sure that the .NET Core SDK is installed and on the path.
Thinking that the cause might be that the path was not set, I added the path of the installed SDK to .zshrc.
% which dotnet
/usr/local/share/dotnet/dotnet
export DOTNET_ROOT="/usr/local/share/dotnet/dotnet"
export PATH=$PATH:$DOTNET_ROOT
However, the error continued to be displayed even after reopening the project.
Solution found in the relevant issue
Since .NET Core is an OSS platform, the SDK repository is also public.
When I tried searching for dotnet: command not found, I found a likely-looking issue at the top.
I have macOS 12.0.1
When I open a project on visual studios, the message says that I need to install .net core 3.1. But when I download it, nothing changes and I still cannot run the the command dotnet
I would appreciate, if someone helped meProblem encountered on https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install
Operating System: macosProvide details about the problem you're experiencing. Include your operating system version, exact error message, code sample, and anything else that is relevant.
It seems that a similar issue occurs in Mac environments equipped with M1 chips or later, which use the arm64 architecture. After skimming through the comments, it appeared that the issue could be resolved by creating a symbolic link.
After installation the symlink is missing, which is likely due to SIP (System Integrity Protection).
I tried to do this manually by disabling SIP and running the following command.
ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/
It creates the file just fine, however terminal still can't see it.
Even adding it to the PATH for .zshrc doesn't work.It looks like dotnet is installed correctly, but just can't be accessed...
This is about as far as I have got.
https://github.com/dotnet/sdk/issues/22910#issuecomment-986186872
Therefore, I will create a symbolic link for the SDK installation path. If you want to change an existing symbolic link, you can overwrite it with the -nfs option of the ln command.
% sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin
With this adjustment, the error message successfully disappeared.
I'm grateful that Macs with Apple Silicon chips have become quiet and comfortable, but it's quite a nuisance that there are many such troubles when setting up development environments.
Discussion
こちらの記事のお陰でdotnetコマンドが実行できるようになりました
私の環境(m2 mac)では
/usr/local/share/dotnet/dotnetに実行バイナリがあったためsudo ln -s /usr/local/share/dotnet/dotnet /usr/local/binで対応しましたコメントありがとうございます!
お役に立てて何よりです😊