-
Notifications
You must be signed in to change notification settings - Fork 36.5k
Use command -v to detect git #82552
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
Use command -v to detect git #82552
Conversation
There is a node package called which: https://www.npmjs.com/package/which If this package is installed through Node, _and_ a user is using asdf, this which-from-node can take precedence in $PATH. This will cause issues if there is no default Node version specified for asdf. An error like this can appear: asdf: No version set for command which you might want to add one of the following in your .tool-versions file: nodejs 8.14.0 (I suspect this is only an issue on 'zsh' terminals) To work around this which-conflict, we should use the built-in 'command' command. This comes standard in every shell program and is a viable alternative to 'which'.
Naming the executable of this library `which` can cause issues -- such as microsoft/vscode#82552. I would like to suggest renaming this executable to `node-which`, so that people can clearly differentiate between built-in `which` (bash, zsh, etc) and the Node version.
|
👀 |
Naming the executable of this library `which` can cause issues -- such as microsoft/vscode#82552. I would like to suggest renaming this executable to `node-which`, so that people can clearly differentiate between built-in `which` (bash, zsh, etc) and the Node version.
|
So... what happens if the user has a |
|
Closing. |
I believe that wouldn't be a problem because the shell builtin From bash manual: Shell Builtin Commands
|
|
Isn't |
In csh |
|
Got it. Keeping my opinion: this is not worth the trouble. |
Naming the executable of this library `which` can cause issues -- such as microsoft/vscode#82552. Rename executable to `node-which`, so that people can clearly differentiate between built-in `which` (bash, zsh, etc) and the Node version. PR-URL: #67 Credit: @radar Close: #67 Reviewed-by: @isaacs
Version details:
What I expect to happen
VS Code's Git extension finds + uses Git
What actually happens
VS Code says it cannot find Git:
Steps to reproduce
TL;DR: VS Code should use
command -vto detect commands, notwhich.This is a bit tricky, so bear with me:
There is a node package called which:
https://www.npmjs.com/package/which
If this package is installed through Node, and a user is using asdf, this which-from-node can take precedence in $PATH. This will cause issues if there is no default Node version specified for asdf. An error like this can appear:
(I suspect this is only an issue on 'zsh' terminals -- I am unable to reproduce it in Bash)
To work around this which-conflict, we should use the built-in 'command' command. This comes standard in every shell program and is a viable alternative to 'which'.
When my shell works correctly, here's the output of
which -a which:However, when it is misbehaving, I suspect the order is like this:
And that's why it's trying to use the node
which. When no node version is configured forasdf, then it fails to run that node-which, which then causes this extension to claim that it can't find git.This PR (likely) fixes #81287 -- although I'm not 100% sure of that.