Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bad Substitution in nvm.sh #168

Closed
togakangaroo opened this Issue Nov 11, 2012 · 11 comments

Comments

Projects
None yet
8 participants

On a fairly fresh Ubuntu 12.04 install I get

gmauer:/nvm$ sudo ./nvm.sh
./nvm.sh: 10: ./nvm.sh: Bad substitution
./nvm.sh: 75: ./nvm.sh: [[: not found
./nvm.sh: 75: ./nvm.sh: [[: not found
./nvm.sh: 126: ./nvm.sh: [[: not found
gmauer:
/nvm$ -e N/A

This is both in bash and zsh

not using sudo, as far as I can tell the script just exits immediately with no output.

Any ideas?

Contributor

koenpunt commented Nov 12, 2012

Executing nvm.sh just loads the nvm functions in your shell, so indeed no output is given. I don't know what's causing the Bad substitution, also because I'm not using nvm width sudo myself.

Owner

creationix commented Nov 13, 2012

Nvm is not meant to be run this way. It is to be sourced in your bash
profile or rc file. If you want to use it as root, then root needs to
source the file.
On Nov 11, 2012 12:04 PM, "George Mauer" notifications@github.com wrote:

On a fairly fresh Ubuntu 12.04 install I get

gmauer:/nvm$ sudo ./nvm.sh
./nvm.sh: 10: ./nvm.sh: Bad substitution
./nvm.sh: 75: ./nvm.sh: [[: not found
./nvm.sh: 75: ./nvm.sh: [[: not found
./nvm.sh: 126: ./nvm.sh: [[: not found
gmauer:
/nvm$ -e N/A

This is both in bash and zsh

not using sudo, the script just exits immediately. Any ideas?


Reply to this email directly or view it on GitHubhttps://github.com/creationix/nvm/issues/168.

Running nvm in zsh without sudo:


[gmauer]$ ./nvm.sh                                                (11-12 22:36)
./nvm.sh: 10: ./nvm.sh: Bad substitution
./nvm.sh: 75: ./nvm.sh: ./nvm.sh: 75: ./nvm.sh: [[: not found
[[: not found
[gmauer]$ ./nvm.sh: 126: ./nvm.sh: [[: not found                  (11-12 22:36)
-e             N/A

Running nvm in bash without sudo doesn't have an error but doesn't seem to load nvm functions either:


[gmauer]$ bash                                                    (11-12 22:36)
gmauer@gmauer-ThinkPad-T420:~$ cd nvm
gmauer@gmauer-ThinkPad-T420:~/nvm$ ./nvm.sh
gmauer@gmauer-ThinkPad-T420:~/nvm$ cd ..
gmauer@gmauer-ThinkPad-T420:~$ nvm use
No command 'nvm' found, did you mean:
 Command 'nvi' from package 'nvi' (universe)
 Command 'pvm' from package 'pvm' (universe)
 Command 'lvm' from package 'lvm2' (main)
 Command 'vm' from package 'mgetty-voice' (universe)
 Command 'rvm' from package 'ruby-rvm' (universe)
 Command 'nm' from package 'binutils' (main)
 Command 'nm' from package 'binutils-multiarch' (universe)
 Command 'nam' from package 'nam' (universe)
 Command 'npm' from package 'npm' (universe)
 Command 'kvm' from package 'qemu-kvm' (main)
nvm: command not found
gmauer@gmauer-ThinkPad-T420:~$ 

This is on a relatively fresh Ubuntu install. I've gotten it running before but that was on my old install which I had been loading with crap for 6 months.

Contributor

Marsup commented Nov 13, 2012

You are supposed to source it, either by calling source /your/path/to/nvm.sh or the shortcut version . /your/path/to/nvm.sh (notice the separated dot at the beginning).

Collaborator

ljharb commented Jun 14, 2013

Closing this. nvm.sh is not meant to be executed directly.

@ljharb ljharb closed this Jun 14, 2013

even with a space in sh:

. ~/.nvm/nvm.sh
/bin/sh: 78: //.nvm/nvm.sh: [[: not found
/bin/sh: 78: //.nvm/nvm.sh: [[: not found
/bin/sh: 132: //.nvm/nvm.sh: [[: not found
-e
N/A
... hang.
^C

This is still a problem in sh shell in ubuntu at least.

bugmen0t commented Feb 5, 2014

Sourcing this within the sh shell causes errors still, because certain bash features are being used, which are nonexistent within sh. Is there a way this could be fixed? I really need to source this in a sh shell for my upstart script...

Collaborator

ljharb commented Feb 5, 2014

@bugmen0t PRs welcome

Collaborator

ljharb commented Nov 2, 2014

@bugmen0t Do you still have issues with this? We shouldn't be using bash features anymore, but specific filed issues are appreciated.

I have issuse with this using alpine linux.

Collaborator

ljharb commented Jun 14, 2017

@NullVoxPopuli this is a 4-year-old issue, 2 years stale. Would you mind filing a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment