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

With .Net 5 Preview, failed to run tool dotnetsay on Mac due to command not found #10986

Closed
NicoleWang001 opened this issue Mar 25, 2020 · 7 comments
Assignees
Milestone

Comments

@NicoleWang001
Copy link
Member

Repro steps-

  1. On Mac OS 10.15, install SDK 5.0.100-preview.2.20169.1 & Runtime 2.1.17
  2. Run below commands
    dotnet tool install -g doTNetsay
    dotnet tool list -g
    dotnetsay

Actual Result-
Failed to run tool dotnetsay on Mac due to command not found
image

Note-

  1. This issue is not repro on Windows 10 and Ubuntu 16.04
  2. This issue is not repro with User-built global tool.
  3. This issue is also repro on .Net 5 Preveiw1
@memark
Copy link

memark commented Mar 25, 2020

@yuki233 I'll try to reproduce. Where can I find preview 2?

I ran in to a similar issue earlier due to zsh path handling. Try invoking the tool directly with
~/.dotnet/tools/dotnetsay

If that works, try the following to confirm
path+=~/.dotnet/tools
dotnetsay

@NicoleWang001
Copy link
Member Author

@memark This issue is also reproduced with .Net 5.0 Preview 1

Run ~/.dotnet/tools/dotnetsay, dotnetsay works fine
image

Run below command, dotnetsay works fine
path+=~/.dotnet/tools
dotnetsay
image

@memark
Copy link

memark commented Mar 26, 2020

Then the issue appears to be with zsh. If you switch to bash, you will probably find that it works.

From what I can tell this is what happens:

  • The file /etc/paths.d/dotnet-cli-tools is read when the shell spawns.
  • It contains ~/.dotnet/tools which is added to $PATH.
  • However, it doesn't get resolved and stays as ~/.dotnet/tools in $PATH.
  • This doesn't work in zsh, but does work in bash.

When manually adding ~/.dotnet/tools to $PATH, it gets resolved immediately and ends up as e.g. /Users/memark/.dotnet/tools in $PATH, which works in both shells.

So the issue appears to be with /etc/paths.d/dotnet-cli-tools.

I also tried replacing the file contents with $HOME/.dotnet/tools, but that gives the same problem.

@marcpopMSFT marcpopMSFT added the untriaged Request triage from a team member label Apr 6, 2020
@dsplaisted
Copy link
Member

@wli3 This looks to be a path expansion issue when setting the path to the tools folder in zsh: #10986 (comment)

@dsplaisted dsplaisted assigned wli3 and unassigned dsplaisted Apr 9, 2020
@wli3
Copy link

wli3 commented Apr 9, 2020

If your default shell zsh?

We do have an experience to guide zsh user to add path to .zprofile dotnet/cli#11926 when detect the user's default shell is zsh

at the same time:

Mac don’t have a good solution to put user path for all user (/USERNAME/home/.dotnet/tools is different for different user). We currently adding literal ~/.dotnet/tools for all users. And that works for bash. But it no longer works for zsh.

At the same time, directly adding new lines to .zprofile is not “idiomatic” for unix. So we can only use existing fallback experience. (bash will have the same experience is you install it via tar.gz).

I find there are 3 ways you can detect the application is running on zsh. (a)$SHELL (b)$ZSH_NAME and use (c)ps -p $$

Only (a) can work in a dotnet program. If you run Console.WriteLine(Environment.GetEnvironmentVariable("ZSH_NAME", EnvironmentVariableTarget.Process)); you will get nothing, even when echo $ZSH_NAME can give you the value in the same session. I don’t know why at this moment. (c) won’t work since $$ is “the current process”. It can only work for scripts. However, the downside of $SHELL is, it will only give you the default shell. That means if you run zsh on top of bash, we will not detect that. I verified in macOS 10.15 VM if it has $SHELL set. (after running chsh -s /bin/zsh)

More info in #9415

@memark
Copy link

memark commented Apr 9, 2020

@wli3, thank you! Seems this has been known for some time. Apparently both @yuki233 and I missed the message on modifying our paths...

I would suggest giving #3992, which addresses the visibility issue, some love.

@wli3 wli3 removed the untriaged Request triage from a team member label Apr 20, 2020
@wli3 wli3 added this to the Backlog milestone Apr 20, 2020
@wli3
Copy link

wli3 commented Apr 20, 2020

I will consider the issue resolved. If you have more ask please create a more specific issue.

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

No branches or pull requests

5 participants