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 install result with -bash: [: -ne: unary operator expected #2968

Closed
electriquo opened this issue Dec 11, 2022 · 3 comments
Closed

nvm install result with -bash: [: -ne: unary operator expected #2968

electriquo opened this issue Dec 11, 2022 · 3 comments

Comments

@electriquo
Copy link

Operating system and version:

nvm debug output:

nvm --version: v0.39.2
$TERM_PROGRAM: iTerm.app
$SHELL: /usr/local/bin/bash
$SHLVL: 1
whoami: 'foo'
${HOME}: /Users/foo
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.pyenv/shims:${HOME}/.forgit/bin:${HOME}/.rbenv/shims:/usr/local/Cellar/ruby/3.1.3/bin:${HOME}/.cargo/bin:${NVM_DIR}/versions/node/v18.12.1/bin:/usr/local/Cellar/python@3.10/3.10.8/libexec/bin:/usr/local/Cellar/mysql-client/8.0.31/bin:/usr/local/Cellar/openssl@3/3.0.7/bin:/usr/local/Cellar/openjdk/19.0.1/bin:/usr/local/Cellar/openssh/9.1p1/bin:/usr/local/lib/ruby/gems/3.1.0/bin:/usr/local/Cellar/ruby/3.1.3/bin:/usr/local/Cellar/curl/7.86.0/bin:/usr/local/sbin:${HOME}/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/Cellar/fzf/0.35.1/bin:${HOME}/.rd/bin:/usr/local/opt/fzf/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.2.12(1)-release (x86_64-apple-darwin21.6.0)'
uname -a: 'Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64'
checksum binary: 'sha256sum'
OS version: macOS 13.0.1 22A400
curl: /usr/local/Cellar/curl/7.86.0/bin/curl, curl 7.86.0 (x86_64-apple-darwin21.6.0) libcurl/7.86.0 (SecureTransport) OpenSSL/1.1.1s zlib/1.2.11 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libssh2/1.10.0 nghttp2/1.51.0 librtmp/2.3
wget: /usr/local/bin/wget, GNU Wget 1.21.3 built on darwin21.3.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.38.2
grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
awk: /usr/local/bin/awk, GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.1.0-p13, GNU MP 6.2.1)
nvm current: v18.12.1
which node: ${NVM_DIR}/versions/node/v18.12.1/bin/node
which iojs:
which npm: ${NVM_DIR}/versions/node/v18.12.1/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v18.12.1
npm root -g: ${NVM_DIR}/versions/node/v18.12.1/lib/node_modules

nvm ls output:

->     v18.12.1
default -> lts/* (-> v18.12.1)
system -> stable (-> v18.12.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.12.1) (default)
stable -> 18.12 (-> v18.12.1) (default)
lts/* -> lts/hydrogen (-> v18.12.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.1 (-> N/A)
lts/gallium -> v16.18.1 (-> N/A)
lts/hydrogen -> v18.12.1

How did you install nvm?

Homebrew

What steps did you perform?

$ cat .nvmrc
lts/*

$ nvm install

What happened?

Running nvm install result with -bash: [: -ne: unary operator expected

$ nvm install
Found '/Users/foo/test/.nvmrc' with version <lts/*>
v18.12.1 is already installed.
Now using node v18.12.1 (npm v9.2.0)
-bash: [: -ne: unary operator expected
-bash: [: -ne: unary operator expected
-bash: [: -ne: unary operator expected

$ echo $?
0

Seems to be related to #2920, #2914. If it is, I hope the issue will be resolved with the next release.

What did you expect to happen?

Expected not to have -bash: [: -ne: unary operator expected printed

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

Yes

@princefishthrower
Copy link

I also had this weird output (despite nvm still installing things just fine). I notice it only shows up if you try and install a version you already have. I nuked ~/.nvm and reinstalled the latest fresh in hopes to fix it, but this still appears...

To be clear, this doesn't appear to effect the actual ability of nvm to install node versions, it's just a bit annoying / concerning.

(As an aside, another strange thing I notice is issuing which nvm - it doesn't list the location like it should but the source of nvm itself? Very strange...)

@electriquo
Copy link
Author

@princefishthrower

As an aside, another strange thing I notice is issuing which nvm - it doesn't list the location like it should but the source of nvm itself? Very strange...

That is because nvm command is a function and not a file

$ declare -F | grep ' nvm$'
declare -f nvm

@ljharb
Copy link
Member

ljharb commented Dec 11, 2022

This is a duplicate of #2914, and will be fixed in the next release.

Indeed, which nvm shouldn't work because nvm isn't a binary.

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants