Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh: command not found: dotnet on Mac m1 #22910

Open
orrloshka opened this issue Nov 21, 2021 · 42 comments
Open

zsh: command not found: dotnet on Mac m1 #22910

orrloshka opened this issue Nov 21, 2021 · 42 comments
Assignees

Comments

@orrloshka
Copy link

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 me

Problem encountered on https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install
Operating System: macos

Provide details about the problem you're experiencing. Include your operating system version, exact error message, code sample, and anything else that is relevant.

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Nov 22, 2021

Assuming you used the installer and it ran to completion, it will place the dotnet executable in the /usr/local/bin folder. Does /usr/local/bin/dotnet --info work for you? If it doesn't then the sdk was not installed successfully and you should retry. If it does, then it's likely that your PATH environment variable is not configured correctly.

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Nov 22, 2021

Out of curiosity, is this an intel or apple silicon mac?

EDIT: I guess the answer is on the issue title. Mine's an intel mac and the installer seems to be working fine.

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Nov 22, 2021

cc @wli3 @dsplaisted since we're seeing multiple reports of this happening.

@dsplaisted
Copy link
Member

@richlander @marcpopMSFT to route. Looks like an M1 Mac issue.

@BeauNouvelle
Copy link

Anyone have a work around?

@BeauNouvelle
Copy link

BeauNouvelle commented Dec 5, 2021

EDIT: ignore, see next comment.

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.

@BeauNouvelle
Copy link

BeauNouvelle commented Dec 5, 2021

Nevermind, I had the path wrong:

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

The path has changed, so there's an /x64/ in there now.
This should get it working again.

@eiriktsarpalis eiriktsarpalis transferred this issue from dotnet/core Dec 6, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels Dec 6, 2021
@eiriktsarpalis
Copy link
Member

Getting many customer reports on this error:

dotnet/core#6979
dotnet/core#6972
dotnet/core#6957
dotnet/core#6924
dotnet/core#6951
dotnet/core#6933

Could we please prioritize this?

@dsplaisted
Copy link
Member

Hi folks,

This issue should describe how the .NET SDK works on M1 machines and what we recommend: #22380

In general, you should only install the ARM64 versions of the SDK and not any of the x86 ones (uninstall them if you already did), and things will work a lot better.

@BeauNouvelle
Copy link

BeauNouvelle commented Dec 10, 2021

@dsplaisted This answer has been posted a few times, but it won't solve the entire issue.

It seems as though the file path has changed, and so it's not getting linked correctly.
I deleted and re-installed the arm version the other day and had to manually symlink myself to get it working.

The install paths for arm are missing /x64/

There are loads of helpful comments there, but could take a while for anyone to search through to find what works for them. Ideally the installer gets an update.

@tjpegram
Copy link

Hi folks,

This issue should describe how the .NET SDK works on M1 machines and what we recommend: #22380

In general, you should only install the ARM64 versions of the SDK and not any of the x86 ones (uninstall them if you already did), and things will work a lot better.

This is not a valid solution to this issue. There are several frameworks that only support .net core 3.1 rather than the SDK which does not solve the issue of the command not working, thus microsoft should find a fix for this.

@techcolin
Copy link

For what it's worth, I only got this issue after upgrading to Monterey. It was fine on my M1 on Big Sur. Not sure what the upgrade did, but I verified the path had changed and created the symlink as above.

@greenEkatherine
Copy link

Here is that issue again dotnet/core#7170

@BeauNouvelle
Copy link

Lol this is seriously still a thing?

@ingcrengifo
Copy link

With the version v6.0.102 the same error.

I needed sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin to fix it

@marcpopMSFT
Copy link
Member

CC @richlander

@wpmcdonnell
Copy link

wpmcdonnell commented Mar 4, 2022

I use bash but still... I have a new m1 mac aka arm64 architecture

  • Aam64 .Net 6 for mac os installs to usr/local/share/dotnet/

  • x64 .Net 5 installs to usr/local/share/dotnet/x64

If you download both, you are going to have a nightmare of a time uninstalling correct versions and getting paths for dotnet correct, like I did. If you download .NET 5 x64 after .NET 6 arm64, it will look like this usr/local/share/dotnet/x64 with runtimes and sdks duplicated and scattered about between dotnet and x64

So what did I do?

1.) I removed the usr/local/share/dotnet folder to completely start from the beginning - i saw this wasn't recommended but after struggling with the uninstall core tool and recommended commands for version deletions, I went for it. Always be careful when deleting folders from your system, this will probably break VS code for .NET and you will have to repair it

2.) then i download .NET 5 x64 for mac os even tho I have an arm64 chip.

3.) I installed rosetta via CLI which lets intel apps run on arm64

4.) Dotnet command still doesnt work cause arm64 chip is expecting a different path, so I use command from above
sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin

5.) I exit terminal, Ctrl+q my terminal

6.) re-open terminal

7.) run dotnet --version and you should have your desired .Net x64 version running on your new M1 macbook, in my case .NET 5

@NuclearFishin
Copy link

Hi all, I've just encountered the command not found: dotnet issue setting up a new M1 Mac to develop my .NET 5 project. Specifically the steps I took were, from first power-on:

  1. Update MacOS software updates

    • Monterey 12.2.1 (21D62)
  2. Install .NET 5 SDK via the MacOS x64 installer

At this point I received the zsh: command not found: dotnet error. Hopefully this is a simple enough case for reproduction!

  1. I then tried installing the .NET 6 SDK via the MacOS ARM64 installer

Unfortunately I still received the error zsh: command not found: dotnet. I was really expecting this one to work.

Like several commenters above, adding a symbolic link to /usr/local/bin/dotnet does work, linking to /usr/local/share/dotnet/x64/dotnet for .NET 5, or /usr/local/share/dotnet/dotnet for .NET 6.

Is this the "official" solution for now? I.e., is the symlink the only part of the installation that failed?

(Happy to provide installation logs if they exist)

@BeauNouvelle
Copy link

@NuclearFishin

Not official until they acknowledge the issue.
The maintainers are still "maintaining" that the solution is to install the ARM64 version.

@AlbertoLeon
Copy link

I installed the ARM64 version and I have the same issue.
As mentioned before, executing sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin fixed it.

@victorcappa
Copy link

MacOs 12.3.1, tried the above solutions but none seems to work

@ATANG09
Copy link

ATANG09 commented Apr 15, 2022

EDIT: ignore, see next comment.

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.

cool

@Filliny
Copy link

Filliny commented Nov 21, 2022

MacOs 12.3.1, tried the above solutions but none seems to work
cos even all here says that dotnet sits in /usr/local/share/dotnet/dotnet its installs in /usr/local/share/dotnet/dotnet /Users//.dotnet/dotnet

@DenisDolmatov2020
Copy link

brew install dotnet

@hamid-dataroots
Copy link

hamid-dataroots commented Nov 30, 2022

run this command and it will fix your issue
ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/

@init-center
Copy link

This problem still exists, need to manually create a link after install

@Bhaney44
Copy link

The pathing problem is very difficult to solve because the there is no way to know where the installation happens without doing a lot of digging.

IN:
dotnet

OUT:
zsh: command not found: dotnet

I need to find a way to install dotnet locally, such that I can actually use the software. Any advice or suggestions would be appreciated. Thanks!

@Bhaney44
Copy link

IN:

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

OUT:

ln: /usr/local/bin//dotnet: Permission denied

I am not sure why Apple developed such a terrible chip in the M1. But, it is very difficult to navigate the terminal when the system denies the admin. Any advice would be appreciated. Thanks.

@EHampton252
Copy link

I managed to install dotnet by using Homebrew:

brew install dotnet

@meadow-kun
Copy link

chiming in here, Mac M1 as well and had this problem too. Symlink fix above worked for me.

@PabloLION
Copy link

for Mac M1, you need to sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/ without sudo it wont work. @Bhaney44

@Fhwang0926
Copy link

i using intel imac, my case erase all and reinstall dodtnet 6.0.x, refer it https://stackoverflow.com/questions/44089518/how-can-i-uninstall-dotnet-core-from-macos-sierra

@pms1969
Copy link

pms1969 commented Mar 14, 2023

M1 Mac and the install location for dotnet is ~/.dotnet/dotnet.
globab tools just don't work, and linking /usr/local/bin/dotnet to the installed version does not work either. Anything I can do?

@NathanielOctaviano
Copy link

I am so stuck in this problem "dotnet not found" until I installed the .NET SDK Arm64 in this link
https://dotnet.microsoft.com/en-us/download
Just click the arrow down button and it will show the .NET SDK Arm64 option, download it and try the command dotnet in your terminal. Mine's working already

@ch3ck3r3d
Copy link

With the version v6.0.102 the same error.

I needed sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin to fix it

M2 Pro and had the same issue for v7.0.203, this fixed the problem for me. Although v7 is in STS I am waiting for v8 to get out of preview.

@navid-kianfar
Copy link

in Mac M1 you also need to create the bin folder in "/usr/local" if it does not exists

sudo mkdir /usr/local/bin

then you may run:

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

@LanguageXange
Copy link

I had the same issue on Mac M1 as well
( I downloaded the .NET 7.0 SDK (v7.0.306) - macOS Arm64 )

and this command works for me
sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin

Kudos to all the people sharing the solution above

@baronfel baronfel added Area-Install and removed untriaged Request triage from a team member Area-CLI labels Aug 1, 2023
@GuySerg
Copy link

GuySerg commented Aug 31, 2023

Had the same issue on MacBook Pro M1.

Got dotnet bundled with Rider. Didn't have /usr/local/share, /usr/local/bin folders on my machine, symlink didn't work.
Managed the issue by updating my environment variables for the zsh shell. I added this line to the .zprofile:

export PATH="$PATH:$HOME/.dotnet"

You might need also to reload your profile to pick up changes. Also, be aware that on some systems these changes could be rewritten by other zsh shell-related configs.

@kedzior-io
Copy link

Had the same issue on MacBook Pro M1.

Got dotnet bundled with Rider. Didn't have /usr/local/share, /usr/local/bin folders on my machine, symlink didn't work. Managed the issue by updating my environment variables for the zsh shell. I added this line to the .zprofile:

export PATH="$PATH:$HOME/.dotnet"

You might need also to reload your profile to pick up changes. Also, be aware that on some systems these changes could be rewritten by other zsh shell-related configs.

@GuySerg that worked for M2 as well.

@Pamavoc
Copy link

Pamavoc commented Dec 5, 2023

NuclearFishin

Thanks, worked for me with a M1 config, SDK 8 :

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

@vmaryanne82
Copy link

I use bash but still... I have a new m1 mac aka arm64 architecture

  • Aam64 .Net 6 for mac os installs to usr/local/share/dotnet/
  • x64 .Net 5 installs to usr/local/share/dotnet/x64

If you download both, you are going to have a nightmare of a time uninstalling correct versions and getting paths for dotnet correct, like I did. If you download .NET 5 x64 after .NET 6 arm64, it will look like this usr/local/share/dotnet/x64 with runtimes and sdks duplicated and scattered about between dotnet and x64

So what did I do?

1.) I removed the usr/local/share/dotnet folder to completely start from the beginning - i saw this wasn't recommended but after struggling with the uninstall core tool and recommended commands for version deletions, I went for it. Always be careful when deleting folders from your system, this will probably break VS code for .NET and you will have to repair it

2.) then i download .NET 5 x64 for mac os even tho I have an arm64 chip.

3.) I installed rosetta via CLI which lets intel apps run on arm64

4.) Dotnet command still doesnt work cause arm64 chip is expecting a different path, so I use command from above sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin

5.) I exit terminal, Ctrl+q my terminal

6.) re-open terminal

7.) run dotnet --version and you should have your desired .Net x64 version running on your new M1 macbook, in my case .NET 5

This is the perfect reply

@BhargavaVidiyala
Copy link

"sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin " Enter this in terminal and then asks for password, then this issue gets solved . (My device is M1 Mac)
Kudos to all the people sharing the solution above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests