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

Tool with command name dotnet-foo is not available as cli verb #9022

Closed
dasMulli opened this issue Jan 23, 2018 · 8 comments
Closed

Tool with command name dotnet-foo is not available as cli verb #9022

dasMulli opened this issue Jan 23, 2018 · 8 comments
Assignees
Labels
Milestone

Comments

@dasMulli
Copy link
Contributor

Steps to reproduce

  1. Create and install a tool with
  <PropertyGroup>
    <ToolCommandName>dotnet-greet</ToolCommandName>
  </PropertyGroup>
  1. execute dotnet-greet, observe that the program runs
  2. execute dotnet greet, observe that the program does not run
No executable found matching command "dotnet-greet"

Workaround:

Martins-MacBook-Pro:~ martin$ cp ~/.dotnet/tools/dotnet-greet /usr/local/bin/
Martins-MacBook-Pro:~ martin$ which dotnet-greet
/usr/local/bin/dotnet-greet
Martins-MacBook-Pro:~ martin$ dotnet greet
Hi martin!

Expected behavior

Tools named dotnet-{x} should be available as CLI verb to be used as dotnet {x}.

Actual behavior

The CLI does not search PATH entries prefixed with ~/ for candidate executables and fails to run the global tool as CLI verb.

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.300-preview2-008012)

Product Information:
 Version:            2.1.300-preview2-008012
 Commit SHA-1 hash:  c9ac5c9c02

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.300-preview2-008012/

Microsoft .NET Core Shared Framework Host

  Version  : 2.1.0-preview1-26116-04
  Build    : eeb3a84e2142aba791fe003564b8afd048c45ff9

cc @wli3 @livarcocc

@livarcocc
Copy link
Contributor

@dasMulli thanks for the bug report.

I assume this is a global tool? And also that your failing command there is for dotnet greet instead of dotnet-greet?

@dasMulli
Copy link
Contributor Author

Yes the repro was supposed to be a CLI verb to be packed and installed as global tool.

@dasMulli
Copy link
Contributor Author

@dasMulli
Copy link
Contributor Author

Works just fine on windows, just not when using all the defaults on Mac. (didn't try any linux)

@wli3 wli3 self-assigned this Jan 23, 2018
@wli3
Copy link

wli3 commented Jan 23, 2018

as @dasMulli stated, resolver should find dotnet-X on the PATH and make it dotnet X. And due to mac path_helper limitation, what ends up on the PATH start with "~/" (Linux should be fine). Let me see if we can do something on the command resolver.

@wli3
Copy link

wli3 commented Jan 23, 2018

This will be a problem for dotnet-watch, the walk around is adding path by bash_profile, which is the instruction if the user install via a tar.gz. Copy paste the following to shell

cat << EOF >> ~/.bash_profile
# Add .NET Core SDK tools
export PATH="$PATH:$HOME/.dotnet/tools"
EOF

cc @natemcmaster

@wli3 wli3 changed the title [tool] Tool with command name dotnet-foo is not available as cli verb Tool with command name dotnet-foo is not available as cli verb Jan 24, 2018
@wli3
Copy link

wli3 commented Feb 9, 2018

Here is the problem
https://github.com/dotnet/cli/blob/fffe3142ad8043743d83885df2166fd2f80dceca/src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs#L72-L80

it simply do a join and search. It won't expend the path with ~/ or $HOME

@dasMulli
Copy link
Contributor Author

exactly. a bit earlier the search paths are calculated

https://github.com/dotnet/cli/blob/fffe3142ad8043743d83885df2166fd2f80dceca/src/Microsoft.DotNet.Cli.Utils/EnvironmentProvider.cs#L43-L50

it may make sense to walk over the list again in *nix to do a ~/ replacement.

@wli3 wli3 closed this as completed Feb 12, 2018
@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 2.1.3xx milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants