dotnet: command not found in Mac

Solution 1:

Make sure your macOS version meets the prerequisites

https://docs.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore2x

If it does, then after installing via the installer, in a new terminal run this command

ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/

Then try dotnet --version

hopefully that should work

EDIT:

You might need to add x64 like so:

ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/

Courtesy of Stan in the comments

Solution 2:

For Mac M1

sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/

If you add symbolic link to /usr/local/bin/ but you get file exist error.

You can delete the dotnet file at /usr/local/bin/

or

at you finder Shift + ⌘ Command + G and type /usr/local/bin/ , delete the dotnet file in finder.

Solution 3:

Just another way how to successfully install dotnet on a Mac: using Homebrew, you can simply run:

brew install dotnet

to have it install. Advantages include automatic updates via brew upgrade and less to worry about permissions or any of the workarounds mentioned as solutions before me.

You can find the formula information here: https://formulae.brew.sh/formula/dotnet