nvm
nvm copied to clipboard
Using Makefile to source with --install or --no-use returns "Error 3"
Operating system and version: Ubuntu 22.04.3 LTS in Docker
nvm debug output:
nvm --version: v0.39.5
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'root'
${HOME}: /root
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.1.16(1)-release (aarch64-unknown-linux-gnu)'
uname -a: 'Linux 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 22.04.3 LTS
random-funcs: srandom/random
regex-funcs: internal
compiled limits:
sprintf buffer 8192
maximum-integer 2147483647
awk: /usr/bin/awk, mawk 1.3.4 20200120
curl: /usr/bin/curl, curl 7.81.0 (aarch64-unknown-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.16
wget: not found
git: not found
grep: /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.7
sed: /usr/bin/sed, sed (GNU sed) 4.8
cut: /usr/bin/cut, cut (GNU coreutils) 8.32
basename: /usr/bin/basename, basename (GNU coreutils) 8.32
rm: /usr/bin/rm, rm (GNU coreutils) 8.32
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.32
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.8.0
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:
N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/hydrogen (-> N/A)
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.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.17.1 (-> N/A)
How did you install nvm?
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
What steps did you perform?
- Create an
.nvmrcfile with the contentv20.4.0 - Create a Makefile:
nvm-install:
. ${NVM_DIR}/nvm.sh --install
nvm-no-use:
. ${NVM_DIR}/nvm.sh --no-use
- Create an ubuntu docker image with nvm installed:
FROM ubuntu:latest
RUN apt-get -y update
RUN apt-get -y install curl
RUN apt-get -y install make
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
- Run a docker container with the current directory mounted as a volume:
docker run -it -v $(PWD):/tmp - In the container run, cd to the mounted directory
/tmpthen runmake nvm-installandmake nvm-no-use
What happened?
Got Error 3 for both command outputs:
root@d235e50c2915:/tmp# make nvm-install
. /root/.nvm/nvm.sh --install
make: *** [Makefile:22: nvm-install] Error 3
root@d235e50c2915:/tmp# make nvm-no-use
. /root/.nvm/nvm.sh --no-use
make: *** [Makefile:25: nvm-no-use] Error 3
What did you expect to happen?
nvm installs the version of node in the .nvmrc file in the directory.
Is there anything in any of your profile files that modifies the PATH?
No. Nothing in the default .bashrc or .profile files in ubuntu:latest has anything that modifies the path.
On my Mac, when I have no default alias and have .nvmrc set to a non-installed version, . $NVM_DIR/nvm.sh has a zero exit code, . $NVM_DIR/nvm.sh --install attempts to install the version, and . $NVM_DIR/nvm.sh --no-use is the same as without --no-use.
I certainly see a lot of your base utilities are the GNU version, so maybe one of those is the issue. Presumably nvm_auto none, nvm_auto install, and nvm_auto use all have the same behavior?
What happens if you set -x and run each of those three commands?
Are you doing this with a Makefile that you're calling in an interactive shell within the Docker container? I think Makefile is messing with something.
make --version output:
GNU Make 4.3
Built for aarch64-unknown-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
No, certainly not; it's certainly possible make is causing the issue - can you run those commands with set -x in the makefile?
In docker, each "RUN" needs to re-source nvm.sh due to the way docker works (that's my understanding, at least).
Either way, closing since there's been no followup. Happy to reopen if that changes.