nvm-sh / nvm

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

Installed using the script instructions on SailfishOS, but "env: can't execute `node`: No such file or directory" #2229

Open Kabouik opened 4 years ago

Kabouik commented 4 years ago

Operating system and version:

Sailfish OS 3.3.0.16

nvm debug output:

```sh [nemo@Sailfish Templates]$ nvm debug nvm --version: v0.35.3 $SHELL: /bin/bash $SHLVL: 1 ${HOME}: /home/nemo ${NVM_DIR}: '${HOME}/.nvm' ${PATH}: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin $PREFIX: '' ${NPM_CONFIG_PREFIX}: '' $NVM_NODEJS_ORG_MIRROR: '' $NVM_IOJS_ORG_MIRROR: '' shell version: 'GNU bash, version 3.2.57(1)-release (armv7l-unknown-linux-gnueabi)' uname -a: 'Linux 4.4.153-perf #6 SMP PREEMPT Mon Mar 23 15:23:16 UTC 2020 aarch64 GNU/Linux' OS version: Sailfish OS 3.3.0.16 (Rokua) curl: /usr/bin/curl, curl 7.64.0-DEV (armv7l-unknown-linux-gnueabi) libcurl/7.64.0-DEV OpenSSL/1.0.2o zlib/1.2.11 wget: /usr/bin/wget, GNU Wget 1.20.1 built on linux-gnueabihf. git: /usr/bin/git, git version 2.25.0 grep: /bin/grep, BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. awk: /bin/awk, GNU Awk 3.1.5 sed: /bin/sed, GNU sed version 4.1.5 cut: /bin/cut, BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. basename: /bin/basename, BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. rm: /bin/rm, BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. mkdir: /bin/mkdir, BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. xargs: /usr/bin/xargs, BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. nvm current: none which node: which iojs: which npm: npm config get prefix: -bash: npm: command not found npm root -g: -bash: npm: command not found ```

nvm ls output:

```sh [nemo@Sailfish Templates]$ nvm ls ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring N/A ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring ls: invalid option -- 'q' BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary. Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]... List directory contents -1 One column output -a Include entries which start with . -A Like -a, but exclude . and .. -x List by lines -d List directory entries instead of contents -L Follow symlinks -H Follow symlinks on command line -R Recurse -p Append / to dir entries -F Append indicator (one of */=@|) to entries -l Long listing format -i List inode numbers -n List numeric UIDs and GIDs instead of names -s List allocated blocks -lc List ctime -lu List atime --full-time List full date and time -h Human readable sizes (1K 243M 2G) --group-directories-first -S Sort by size -X Sort by extension -v Sort by version -t Sort by mtime -tc Sort by ctime -tu Sort by atime -r Reverse sort order -Z List security context and permission -w N Format N columns wide --color[={always,never,auto}] Control coloring iojs -> N/A (default) node -> stable (-> N/A) (default) unstable -> N/A (default) lts/* -> lts/erbium (-> v12.17.0) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.20.1 (-> N/A) lts/erbium -> v12.17.0 [nemo@Sailfish Templates]$ ```

How did you install nvm?

I used the wget bash script one liner.

What steps did you perform?

Prior to installing nvm using the script, I uninstalled node from my system repo (since I believe nvm is supposed to install it itself in user space) and deleted potential remnants from a prior installation:

sudo zypper remove node
rm -rf ~/.nvm
rm -rf ~/.npm
rm -rf ~/node_modules

I also made sure nothing related to node or nvm was in my ~/.bashrc and ~/.bash_profile. Then I installed nvm using the script instructions in the readme ans sourced ~/.bashrc.

What happened?

I then ran nvm install --lts, which downloaded it but I get this at the end:

v12.17.0 is already installed.
env: can't execute 'node': No such file or directory
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v12.17.0` to unset it.

Running nvm use --delete-prefix v12.17.0 as instructed did not help.

What did you expect to happen?

I tried also other node versions, but every time I will get this env: can't execute node: No such file or directory

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

No:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
alias cmus='export TERM=xterm-color && cmus'
alias cava='export TERM=xterm-color && cava'

# Set default terminal editor
export EDITOR='micro'
export VISUAL='micro'

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

Note that we have an old version of node available for installation through our package repository, and I used to use it successfully, however it's very old and therefore incompatible with many things now. Plus, as far as I understand, installing node from repository is discouraged because it will require root privileges to use npm afterwards, right?

ljharb commented 4 years ago

Hi! You can keep your system version and it shouldn't interfere; installing node from any unofficial source is discouraged (nvm installs node from the only official source, nodejs.org/dist), and using a system node does require sudo for global installs.

Can you check ~/.npmrc for a prefix line? Also, can you confirm if $HOME is a symlink or not (hopefully not)?

Kabouik commented 4 years ago

The version of node we have is in a community repository actually. It is just 4.2.6-1 that was packaged several years ago, but we can probably trust it unless there are known security issues with that version.

I have no ~/.npmrc, and I can confirm $HOME is not a symlink in Sailfish.

ljharb commented 4 years ago

ls: invalid option -- 'q' in your nvm ls output is concerning. Is there a chance that BusyBox has a noncompliant ls?

Kabouik commented 4 years ago

First time I see any issue with ls so I'm not sure. Seems to be standard, no?

[nemo@Sailfish ~]$ ls --version
ls: unrecognized option '--version'
BusyBox v1.31.0 (2020-03-27 07:18:49 UTC) multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctukZ] [-w WIDTH] [FILE]...

List directory contents

    -1  One column output
    -a  Include entries which start with .
    -A  Like -a, but exclude . and ..
    -x  List by lines
    -d  List directory entries instead of contents
    -L  Follow symlinks
    -H  Follow symlinks on command line
    -R  Recurse
    -p  Append / to dir entries
    -F  Append indicator (one of */=@|) to entries
    -l  Long listing format
    -i  List inode numbers
    -n  List numeric UIDs and GIDs instead of names
    -s  List allocated blocks
    -lc List ctime
    -lu List atime
    --full-time List full date and time
    -h  Human readable sizes (1K 243M 2G)
    --group-directories-first
    -S  Sort by size
    -X  Sort by extension
    -v  Sort by version
    -t  Sort by mtime
    -tc Sort by ctime
    -tu Sort by atime
    -r  Reverse sort order
    -Z  List security context and permission
    -w N    Format N columns wide
    --color[={always,never,auto}]   Control coloring
Kabouik commented 4 years ago

Where did you find ls: invalid option -- 'q' actually? I can't see that in what I posted.

ljharb commented 4 years ago

Expand the nvm ls output Details section in your OP. nvm ls shouldn't print out an ls error.

My ls outputs this:

$ ls --version
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
Kabouik commented 4 years ago

Oh damn I missed the expand!

Kabouik commented 4 years ago

Do you think I could try installing gnu-coreutils for instance, see if it replaces ls? Problem is it conflicts with busibox-symlinks-coreutils that came by default, and I'm afraid uninstalling it might break things.

i | busybox-symlinks-coreutils   | Busybox replacements for coreutils                                    | package   
  | gnu-coreutils                | The GNU core utilities: a set of tools commonly used in shell scripts | package 
ljharb commented 4 years ago

I"m not familiar with busybox so I'm not sure :-/ but i believe ls -q is in POSIX, and nvm requires a POSIX shell.

Kabouik commented 4 years ago

I'm not fmailiar with a POSIX shell is. Is that something I can check with echo $SHELL? It says /bin/bash.

ljharb commented 4 years ago

It's a standard, that shells try to comply with. Bash is supposed to be posix-compliant already.