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

dotnet: command not found Mac OS X 10.11.4, dotnet-osx-x64.1.0.0-rc2-3002702.pkg #6119

Closed
shawnrc opened this issue May 17, 2016 · 16 comments
Closed
Assignees

Comments

@shawnrc
Copy link

shawnrc commented May 17, 2016

Steps to reproduce

  1. Run the latest released .NET Core pkg installer: dotnet-osx-x64.1.0.0-rc2-3002702.pkg.
  2. Pull up a fresh instance of your preferred shell.
  3. Run dotnet

Expected behavior

dotnet executes and probably prints usage information because no specific command was passed.

Actual behavior

I'm given this output:

zsh: command not found: dotnet

Environment data

dotnet --info output:

shawn ~  dotnet --info
zsh: command not found: dotnet

¯_(ツ)_/¯

normandy:~ shawn$ /usr/local/share/dotnet/dotnet --info
.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64

This package was found at https://go.microsoft.com/fwlink/?LinkID=798388, and was not the link specified at the actual instruction guide at https://www.microsoft.com/net/core#macosx.

Verifying the hash:

shawn ~ shasum ~/Downloads/dotnet-osx-x64.1.0.0-rc2-3002702.pkg -a 512
5f00fd91e1bbffe55d091c398913847bab0766ab00987d9164826a1c15f2b05eb8b56f801c0625b75161237dd31eb9180b6468b2bbd9c85077caf2fb4cae6e7a  /Users/shawn/Downloads/dotnet-osx-x64.1.0.0-rc2-3002702.pkg

It's also worth mentioning that dotnet does, in fact, exist at /usr/local/share/dotnet/dotnet, but there's definitely no symlink in /usr/local/bin/. While there's definitely no symlink, the more I read about this issue, the more it seems like that's intentional. This is most likely actually a duplicate of #5193 and highlights the insufficiency of using path_helper for zsh users.

@shawnrc shawnrc changed the title dotnet: command not found mac OS X, dotnet-osx-x64.1.0.0-rc2-3002702.pkg dotnet: command not found Mac OS X 10.11.4, dotnet-osx-x64.1.0.0-rc2-3002702.pkg May 17, 2016
@wenjiangtao
Copy link

same problem with u, still do not how to fix it.

@dasMulli
Copy link
Contributor

dasMulli commented May 17, 2016

If you created symlinks manually, they may point to a different directory. execute ls -l $(which dotnet) to see if you have a broken symlink (e.g. pointing to a dotnet/bin directory).
If there is no symlink, you may need to create one manually.

@dasMulli
Copy link
Contributor

Also note that there is another zsh related issue thread: #5193

@flyingsky
Copy link

I just open a new terminal, it works. It's the first time to install. If I use existing terminal before the installer, it seems the path is not effect, so cannot find command 'dotnet'.

@shawnrc
Copy link
Author

shawnrc commented May 17, 2016

@wenjiangtao The quick fix is to just run ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/, which will get you a working dotnet, but doesn't change the fact that adding the entry for dotnet in /etc/paths.d/ doesn't seem to work well for zsh users.

@dasMulli I haven't made any symlinks to the dotnet binary before, and there was nothing referencing it in /usr/local/bin/ at that point.

Also, in reference to that issue, I think the more sensible option would be to just create a symlink in /usr/local/bin/ - it's very likely to already be part of a user's PATH since the project requires you to have brew set up and the latest openssl installed. It seems like zsh doesn't use path_helper by default, or at least, not in the way that the dotnet maintainers expect it to.

@flyingsky I'm not sure if the installer actually added a symlink to /usr/local/bin/ or if zsh actually runs path_helper on your system, but I was definitely not able to run dotnet after opening a new shell or a new instance of zsh. Or maybe I shouldn't assume you're a zsh user, haha.

@blackdwarf
Copy link

What would help, guys, was if any of you would post your .zshrc files and specify are you using oh-my-zsh.

@blackdwarf blackdwarf self-assigned this May 18, 2016
@blackdwarf
Copy link

blackdwarf commented May 20, 2016

Or, at least post how is your path in said files configured. This seems to be the common thread/culprit for this problem.

@pofallon
Copy link

I ran into the same issue. I'm using oh-my-zsh. Here's the relevant portion of my ~/.zshrc:

# User configuration

export PATH="/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin"

Manually creating the symlink to /usr/local/bin/ fixed it for me.

Thanks!

@blackdwarf
Copy link

@pofallon one question: how did you install go? Using brew or their PKG?

@pofallon
Copy link

Good question -- I don't remember :) Most of that predated my switch to zsh (I haven't been using zsh very long).

@pofallon
Copy link

Same process on a different Mac -- same results, and same fix worked. Also using oh-my-zsh. Here's the relevant PATH info:

# User configuration

export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/paul/.rvm/bin:/usr/local/share/dotnet/bin"

I had to manually fix the .rvm stuff when moving to .zsh. I don't remember if I manually added the /dotnet/bin path entry (from RC1) or if an installer added that for me.

@blackdwarf
Copy link

@pofallon aha, good. :) Good in the sense that then I know what the problem is.

So it seems that the main culprit here is the way installer for oh-my-zsh works. It creates a .zshrc file and then puts the $PATH exploded in there. That means that it will overwrite whatever dynamic path is being created using path_helper when you launch a new session of zsh.

The only way to solve this, apart from filing a bug on zsh project, is to back away from using /etc/paths.d/ and go back to symlinking the muxer in /usr/local/bin or /usr/bin even.

/cc @brthor @piotrpMSFT

blackdwarf referenced this issue in blackdwarf/cli May 20, 2016
This change removes adding the path through /etc/paths.d and
goes to adding a symlink to /usr/bin. The reason is that there is
a lot of users who are running into problems with zsh and oh-my-zsh has
a bug in the installer where they generate a .zshrc file with an
exploded $PATH at the time of install. This overrides the dynamic path
that is created with path_helper.

Fixes #3063, #2988, #1567
@shawnrc
Copy link
Author

shawnrc commented May 22, 2016

@blackdwarf Good catch! I also found a similar offending line in my .zshrc:

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin"

At this point, it's been so long since I set up zsh on my machine that I honestly can't remember what's responsible for that line in there, but oh-my-zsh is definitely a likely culprit. To resolve the issue on my end, I've changed the export to this:

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:$PATH"

Which then allows me to do this:

shawn ~ which dotnet
/usr/local/share/dotnet/dotnet

Cheers!

@blackdwarf
Copy link

After some thinking about this, I think that this is really a problem of various different shell installers. We will have documentation to essentially have a workaround to add the symbolic link manually.

@jamisonwight
Copy link

I had the same problem and found that closing my terminal sessions and reopening a new terminal fixed this issue as @flyingsky stated.

blackdwarf referenced this issue in dotnet/cli May 25, 2016
Add updated information to the known issues document about the oh-my-zsh problem and how to solve it.

skip ci please

Fixes #3063, #1567
TheRealPiotrP referenced this issue in dotnet/cli May 25, 2016
Add updated information to the known issues document about the oh-my-zsh problem and how to solve it.

skip ci please

Fixes #3063, #1567
@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-preview2 milestone Jan 31, 2020
@aliozgur
Copy link

Adding /usr/local/share/dotnet to the PATH in .zshrc fixed the problem in my case

# Add .NET to $PATH
export PATH="/usr/local/share/dotnet:$PATH"

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

9 participants