dotnet command is not found in my Mac m1 terminal
Asked Answered
G

3

9

I have downloaded .net5 from official website, but dotnet command isn't recognised by my terminal.

Here's what I have found after some research-

  1. my dotnet folder is present in /usr/local/share/dotnet

  2. I used this command but it didn't work sudo ln -s /usr/local/share/dotnet /usr/local/bin/dotnet

    1. now whenever I enter dotnet in terminal it shows zsh: permission denied: dotnet
  3. I also tried this command and it didn't work sudo ln -s /usr/local/share/dotnet /usr/bin/dotnet

    1. now whenever I enter dotnet in terminal it shows zsh: command not found: dotnet
  4. when I open my .cs file in vscode it shows error as The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.

here's a screenshot for reference enter image description here

What should I do :(

Gripsack answered 12/11, 2021 at 13:52 Comment(2)
Did you install SDK? dotnet tool is a part of SDK, not runtime.Jens
yeah I have installed the SDK from here dotnet.microsoft.com/download/dotnet/thank-you/…Gripsack
N
23

Had the same(ish) issue after installing .NET 6 broke my current .NET 5 installation.

I fixed it by:

1. removing all files of the current dotnet installation.

This is done by deleting the dotnet folder located in /usr/local/share/

(Navigate there using Finders 'go to' feature, or just delete it using the terminal)

2. reinstalling the dotnet sdk

download from https://dotnet.microsoft.com

3. adding a symlink to the current dotnet executable.

Arm64 (M1/M2/M3 Macs):

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

x64 (Intel Macs):

sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/
Narthex answered 22/11, 2021 at 11:18 Comment(7)
thanks JaggerJo it worked!! Can you tell me what does the command does?Gripsack
There are a few dirs where executable files are expected. It is possible to add dirs, but we can also add links to executable files - instead of the actual files. In this case we add a link to the dotnet executable file in a directory that is searched by default.Narthex
Thanks, this worked for me as well. Oddly I had to delete an existing executable named dotnet in /usr/local/bin/ firstCinchonine
I already have .net6 as my first installed version so all I had to do was run: sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/ and it worked. Thank youLaclos
MacPro M1 MacOS 12, doesn't workFructificative
I have MacPro M1, the problem is the folder /usr/local/bin never existed on my Mac tried creating the path & performed step #3. it worked! @HamedZakeryMiab you can give a try.Ichnology
For M3 with Sonoma: sudo ln -s /usr/local/share/dotnet /usr/local/binDownthrow
M
3

I was having issues today with this on my MacBook Air M1. Saw that lot of people were suggesting to use

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

However, this didn't work for me. I looked in the /usr/local/share/dotnet/x64/dotnet dir, and the x64/ dir was not there. Which means that linkng was not going to happen.

So my solution was to take out the x64/ from the path from the command. Then I ran the dotnet command to verify. This worked for me.

Miltonmilty answered 18/7, 2022 at 2:0 Comment(0)
T
1

Somehow I did not had the access to share folder, but you can grant access to the local user.

The dotnet is located in /usr/local/share/dotnet/dotnet on ARM64 So be sure to symbolic link the path right.

Also sudo dotnet if running terminal inside Visual Studio Code

Takeshi answered 17/10, 2022 at 13:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.