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

checksum fails when sha1sum is alias #670

Closed
ghost opened this issue Feb 20, 2015 · 10 comments
Closed

checksum fails when sha1sum is alias #670

ghost opened this issue Feb 20, 2015 · 10 comments
Labels
installing node: checksums This relates to checksum checking of downloaded node archives. shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh

Comments

@ghost
Copy link

ghost commented Feb 20, 2015

on my system sha1sum is an alias

# OS X has no `sha1sum`, so use `shasum` as a fallback
command -v sha1sum > /dev/null || alias sha1sum="shasum"

so all nvm installs fails checksum

cr@MacBook:~|⇒  nvm install 0.11 
######################################################################## 100.0%
nvm_checksum:2: command not found: sha1sum
Checksums do not match.
Binary download failed, trying source.

i can workaround this issue by forcing nvm_checksum() to use shasum
or by removing sha1sum alias

nvm_checksum() {
  # if nvm_has "sha1sum"; then
  #   checksum="$(command sha1sum "$1" | command awk '{print $1}')"
  # elif nvm_has "sha1"; then
  #   checksum="$(command sha1 -q "$1")"
  # else
  checksum="$(shasum "$1" | command awk '{print $1}')"
  # fi
@ghost ghost changed the title checksum fails checksum fails when sha1sum is alias Feb 20, 2015
@ljharb
Copy link
Member

ljharb commented Feb 20, 2015

@bhedana What version of nvm do you have? The latest explicitly checks for aliases to avoid this problem, and it doesn't appear you have the latest.

Also, builtins shouldn't be aliased as a general rule.

Please update your copy of nvm and let me know if it's still a problem.

@ljharb ljharb added installing node: checksums This relates to checksum checking of downloaded node archives. shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. labels Feb 20, 2015
@ghost
Copy link
Author

ghost commented Feb 20, 2015

this was freshly installed today using the command from the readme..

curl https://raw.githubusercontent.com/creationix/nvm/v0.23.3/install.sh | bash

@ljharb
Copy link
Member

ljharb commented Feb 20, 2015

Oops, you're right :-) this is fixed in 820074e which isn't released yet. I'll release an update soon and this will fix your issue.

@ghost
Copy link
Author

ghost commented Feb 20, 2015

so i pulled master just to play and i think these latest changes need a little adjustment to solve my particular issue..

the nvm_is_alias check doesn't appear to be returning as expected

rs@aus-rs01-mac:~|⇒  type "sha1sum"
sha1sum is an alias for shasum

rs@aus-rs01-mac:~|⇒  command alias "sha1sum"
/usr/bin/alias: line 4: alias: sha1sum: not found

again.. the short answer is.. don't alias this command.. :-)

@ljharb
Copy link
Member

ljharb commented Feb 20, 2015

@bhedana hmm, which shell are you using?

@ghost
Copy link
Author

ghost commented Feb 20, 2015

oh yes.. that's probably important... zsh

@ljharb
Copy link
Member

ljharb commented Feb 20, 2015

Thanks - what does nvm_is_alias sha1sum ; echo $? report?

@ghost
Copy link
Author

ghost commented Feb 20, 2015

rs@aus-rs01-mac:~|⇒  nvm_is_alias sha1sum ; echo $?
1

@ljharb
Copy link
Member

ljharb commented Feb 20, 2015

Gotcha, thanks. I do have unit tests for nvm_is_alias that run in zsh, so I think something else is going on, but clearly that subfunction doesn't work in zsh right now. I'll leave this open so that can be fixed - thanks for following up :-)

@ljharb
Copy link
Member

ljharb commented Feb 22, 2015

Fixed with 12ca8f2

@ljharb ljharb closed this as completed Feb 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing node: checksums This relates to checksum checking of downloaded node archives. shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh
Projects
None yet
Development

No branches or pull requests

1 participant