Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet: command not found in Mac

So I downloaded NET Core 2.1 SDK for mac and installed it. But when I run the dotnet command from terminal it throws -bash: dotnet: command not found error.

I am trying to use the dotnet new react to spin up a new .Net Core/React project.

How can I fix this? Thanks!

like image 869
blankface Avatar asked Oct 28 '18 10:10

blankface


People also ask

Where is dotnet installed macOS?

Path differences NET are installed to the normal /usr/local/share/dotnet/ folder. However, when you install the x64 version of . NET 6 SDK, it's installed to the /usr/local/share/dotnet/x64/dotnet/ folder.


2 Answers

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

like image 87
mazaherm Avatar answered Sep 23 '22 21:09

mazaherm


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.

like image 36
Tan Hoo Chuan Nickson Avatar answered Sep 25 '22 21:09

Tan Hoo Chuan Nickson