nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
80.02k stars 8.01k forks source link

`arch -x86_64 nvm install lts/fermium` returns arch: can't find nvm in PATH #2389

Open hjoshi123 opened 3 years ago

hjoshi123 commented 3 years ago

Operating system and version:

Mac OS v11.1 Big Sur Processor: M1

nvm debug output:

```sh nvm --version: v0.37.2 $TERM_PROGRAM: iTerm.app $SHELL: /bin/zsh $SHLVL: 1 whoami: 'hemantjoshi' ${HOME}: /Users/hemantjoshi ${NVM_DIR}: '${HOME}/.nvm' ${PATH}: ${HOME}/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/openjdk/bin:${NVM_DIR}/versions/node/v15.4.0/bin:${NVM_DIR}/versions/node/v15.4.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/go/libexec/bin $PREFIX: '' ${NPM_CONFIG_PREFIX}: '' $NVM_NODEJS_ORG_MIRROR: '' $NVM_IOJS_ORG_MIRROR: '' shell version: 'zsh 5.8 (x86_64-apple-darwin20.0)' uname -a: 'Darwin 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:40:21 PST 2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101 arm64' checksum binary: 'shasum' OS version: macOS 11.1 20C69 curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0 wget: not found sed: /usr/bin/sed cut: /usr/bin/cut basename: /usr/bin/basename rm: /bin/rm mkdir: /bin/mkdir xargs: /usr/bin/xargs git: /usr/bin/git, git version 2.24.3 (Apple Git-128) ls: grep:: No such file or directory grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep) 2.5.1-FreeBSD awk: /usr/bin/awk, awk version 20200816 nvm current: v15.4.0 which node: ${NVM_DIR}/versions/node/v15.4.0/bin/node which iojs: iojs not found which npm: ${NVM_DIR}/versions/node/v15.4.0/bin/npm npm config get prefix: ${NVM_DIR}/versions/node/v15.4.0 npm root -g: ${NVM_DIR}/versions/node/v15.4.0/lib/node_modules ```

nvm ls output:

```sh v14.15.3 -> v15.4.0 default -> node (-> v15.4.0) iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v15.4.0) (default) stable -> 15.4 (-> v15.4.0) (default) lts/* -> lts/fermium (-> v14.15.3) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.23.0 (-> N/A) lts/erbium -> v12.20.0 (-> N/A) lts/fermium -> v14.15.3 ```

How did you install nvm?

Install script in readme

What steps did you perform?

  1. Opened iTerm2 (natively)
  2. Ran arch -x86_64 nvm install lts/fermium to install latest lts.

What happened?

It returns arch: can't find nvm in PATH. This shouldnt happen as nvm is in the path. Somehow with the prefix of Rosetta it doesnt work. Even though if you open the iTerm in Rosetta and install it works.

What did you expect to happen?

nvm should take the prefix and install the node version under rosetta instead of restarting the terminal under Rosetta.

Is there anything in any of your profile files that modifies the PATH?

No

ljharb commented 3 years ago

I think this may be a duplicate of #2350, somewhat. I don’t know how arch works, but presumably it doesn’t inherit the PATH from the invoking shell if that’s the error message you’re getting. If so there’s nothing nvm can really do about that.

hjoshi123 commented 3 years ago

@ljharb I am not sure if problem of arch as this command arch -x86_64 pyenv --version is resolving properly. I am not sure what is the problem though as in why its not getting the path for nvm.

ljharb commented 3 years ago

pyenv is a binary, nvm is a sourced shell function, so nvm.sh needs to be sourced to make it available.

zemse commented 3 years ago

nvm is a sourced shell function, so nvm.sh needs to be sourced to make it available.

I tried doing arch -x86_64 source ~/.nvm/nvm.sh but it gives error "can't find source in PATH". Seems then it doesn't work

Finally what worked for me is duplicating Terminal app, selecting "Open using Rosetta" in get info and then running nvm commands through the duplicated terminal.

Edit: It's been a year, I ran into this problem now, found this thread on Google, and realized my own comment above just helped me lol.