Skip to content

nvm command not found using github actions, works in shell #2847

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

Closed
crispyaus opened this issue Jul 15, 2022 · 6 comments
Closed

nvm command not found using github actions, works in shell #2847

crispyaus opened this issue Jul 15, 2022 · 6 comments

Comments

@crispyaus
Copy link

Operating system and version:

Debian GNU/Linux 11 (bullseye)

nvm debug output:

nvm --version: v0.39.1
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'github-actions'
${HOME}: /home/github-actions
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v16.16.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.10.0-15-cloud-amd64 #1 SMP Debian 5.10.120-1 (2022-06-09) x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Debian GNU/Linux 11  
curl: /usr/bin/curl, curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3
wget: not found
git: /usr/bin/git, git version 2.30.2
grep: /usr/bin/grep, grep (GNU grep) 3.6
awk: /usr/bin/awk, awk: not an option: --version
sed: /usr/bin/sed, sed (GNU sed) 4.7
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: v16.16.0
which node: ${NVM_DIR}/versions/node/v16.16.0/bin/node
which iojs: 
which npm: ${NVM_DIR}/versions/node/v16.16.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v16.16.0
npm root -g: ${NVM_DIR}/versions/node/v16.16.0/lib/node_modules
nvm --version: v0.39.1
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'github-actions'
${HOME}: /home/github-actions
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v16.16.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.10.0-15-cloud-amd64 #1 SMP Debian 5.10.120-1 (2022-06-09) x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Debian GNU/Linux 11  
curl: /usr/bin/curl, curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3
wget: not found
git: /usr/bin/git, git version 2.30.2
grep: /usr/bin/grep, grep (GNU grep) 3.6
awk: /usr/bin/awk, awk: not an option: --version
sed: /usr/bin/sed, sed (GNU sed) 4.7
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: v16.16.0
which node: ${NVM_DIR}/versions/node/v16.16.0/bin/node
which iojs: 
which npm: ${NVM_DIR}/versions/node/v16.16.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v16.16.0
npm root -g: ${NVM_DIR}/versions/node/v16.16.0/lib/node_modules

nvm ls output:

->     v16.16.0
         system
default -> lts/* (-> v16.16.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.16.0) (default)
stable -> 16.16 (-> v16.16.0) (default)
lts/* -> lts/gallium (-> v16.16.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.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.20.0 (-> N/A)
lts/gallium -> v16.16.0

How did you install nvm?

sh install script.

Issue

Running nvm use or any nvm command using GitHub actions in container (appleboy/ssh-action) returns: err: nvm: command not found

If I however ran this in shell normally it is functional. I suspect this is an issue with the way nvm is being installed on the machine, and not being accessible by docker?

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

No

@ljharb
Copy link
Member

ljharb commented Jul 15, 2022

I use nvm in over 300 projects via https://github.com/ljharb/actions/tree/main/node/install - an example is https://github.com/ljharb/qs/blob/e9877e3b6e23907086403dfb7e39dab0fefb86d7/.github/workflows/node-4%2B.yml

It may be because every docker command runs in a fresh shell, so you have to source nvm.sh inside every RUN.

@zachsa
Copy link

zachsa commented Feb 6, 2023

I had a similar problem - answered here: https://askubuntu.com/a/1041348/521202

Ubuntu's default .bashrc is configured NOT to do anything when sourced on non-interactive terminals by default. The .bashrc file must be updated before it can be sourced by non-interactive logins.

@ljharb ljharb closed this as completed Feb 6, 2023
@amapic
Copy link

amapic commented Jun 8, 2024

I had a similar problem - answered here: https://askubuntu.com/a/1041348/521202

Ubuntu's default .bashrc is configured NOT to do anything when sourced on non-interactive terminals by default. The .bashrc file must be updated before it can be sourced by non-interactive logins.

What did you do concretly ?

@zachsa
Copy link

zachsa commented Jun 10, 2024

@amapic

If I remember correctly, I looked for the below code in .bashrc and removed it:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

@amapic
Copy link

amapic commented Jun 10, 2024

@amapic

If I remember correctly, I looked for the below code in .bashrc and removed it:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Thanks for answering. Here's actually what I did after which is perhaps simpler : adding

script: |
  export NVM_DIR=~/.nvm
  source ~/.nvm/nvm.sh
  npm --help

in the github actiion file. It comes from here : appleboy/ssh-action#21 (comment)

@alex-pythonista
Copy link

@amapic
If I remember correctly, I looked for the below code in .bashrc and removed it:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Thanks for answering. Here's actually what I did after which is perhaps simpler : adding

script: |
  export NVM_DIR=~/.nvm
  source ~/.nvm/nvm.sh
  npm --help

in the github actiion file. It comes from here : appleboy/ssh-action#21 (comment)

This has worked for me. Thanks a bunch.

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

5 participants