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

nvm v0.39.6 regression on command hash #3247

Closed
dharrigan opened this issue Dec 5, 2023 · 9 comments
Closed

nvm v0.39.6 regression on command hash #3247

dharrigan opened this issue Dec 5, 2023 · 9 comments
Labels
bugs Oh no, something's broken :-( shell: zsh

Comments

@dharrigan
Copy link

Linux and MacOS

MacOS: nvm 0.39.6
Arch: nvm 0.39.6-1

When sourcing in nvm.sh on MacOS (zsh 5.9 (x86_64-apple-darwin23.0)), no error is encountered, but sourcing in nvm.sh on Arch (zsh 5.9-4) results in the following error nvm:867: command not found: hash

This is due to the commit at cc765cc

The command on MacOS produces no error:

❯ command hash -r

but on Arch with Zsh, it produces the following:

❯ command hash -r
zsh: command not found: hash

-=david=-

@mguomanila
Copy link

mguomanila commented Dec 5, 2023

some shells command hash -r does not work like zsh, but hash -r is ok...maybe can add some condition here.

@ljharb
Copy link
Member

ljharb commented Dec 5, 2023

Indeed, command hash -r works on zsh on my Mac. Is this because zsh is not fully POSIX-compliant?

@ljharb
Copy link
Member

ljharb commented Dec 5, 2023

#3246 attempts to use builtin, but that doesn't exist at all on dash, and fails on ksh.

\hash -r works everywhere except in ksh, which reports hash: -r: unknown option, so that's a pre-existing bug - this might be the solution I go with.

@carlosala
Copy link

What does where hash outputs for you? It might be that you have hash binary.

@ljharb
Copy link
Member

ljharb commented Dec 5, 2023

which hash on bash gives /usr/bin/hash and where hash on zsh gives hash: shell built-in command \n /usr/bin/hash

most everything's a binary tho

@carlosala
Copy link

When you execute command hash it uses /usr/bin/hash, not the built-in command.

@darkfishy
Copy link

Not on zsh 5.9. Running following on zsh returns:

  • command hash => zsh: command not found: hash
  • which hash => hash: shell built-in command
  • where hash => hash: shell built-in command

@mguomanila
Copy link

I'm using zsh version 5.8.1 (x86_64-ubuntu-linux-gnu):

  • $(which hash) : command not found
  • $(where hash) : command not found

my temporary fix:

safe_hash () {
  command hash -r &>/dev/null || hash -r
}

@Vinfall
Copy link

Vinfall commented Dec 6, 2023

Or simply revert the change until #3246 is merged (not sure whether upgrading would overwrite this, but you can reinstall anyway):

sed -i 's/command hash -r/hash -r/g' $NVM_DIR/nvm.sh

@ljharb ljharb closed this as completed in d86f270 Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( shell: zsh
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants