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_HAS_COLORS unbound variable in shell scripts running in Github Actions Ubuntu images #2926

Closed
jobackman opened this issue Oct 26, 2022 · 2 comments

Comments

@jobackman
Copy link

jobackman commented Oct 26, 2022

Operating system and version:

Github actions CI runner: https://github.com/actions/runner-images/blob/ubuntu20/20221024.1/images/linux/Ubuntu2004-Readme.md

nvm debug output:

Run source $HOME/.nvm/nvm.sh
  source $HOME/.nvm/nvm.sh
  nvm debug
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
nvm --version: v0.39.[2](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:2)
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'runner'
${HOME}: /home/runner
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.local/bin:/opt/pipx_bin:${HOME}/.cargo/bin:${HOME}/.config/composer/vendor/bin:/usr/local/.ghcup/bin:${HOME}/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.15.0-1022-azure #27~20.04.1-Ubuntu SMP Mon Oct 17 02:0[3](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:3):50 UTC 2022 x86_6[4](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:4) x86_64 x86_64 GNU/Linux'
checksum binary: 'sha2[5](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:6)[6](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:7)sum'
OS version: Ubuntu 20.04.5 LTS  
curl: /usr/bin/curl, curl [7](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:8).6[8](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:9).0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.[9](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:10).3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.[20](https://github.com/jobackman/nvm-unbound-variable/actions/runs/3329175279/jobs/5506057361#step:5:21).3 built on linux-gnu.
git: /usr/bin/git, git version 2.38.1
grep: /usr/bin/grep, grep (GNU grep) 3.4
awk: /usr/bin/awk, GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
sed: /usr/bin/sed, sed (GNU sed) 4.7
cut: /usr/bin/cut, cut (GNU coreutils) 8.30
basename: /usr/bin/basename, basename (GNU coreutils) 8.30
rm: /usr/bin/rm, rm (GNU coreutils) 8.30
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.30
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0
nvm current: system
which node: /usr/local/bin/node
which iojs: 
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules

nvm ls output:

Getting this output on the runner is the issue

How did you install nvm?

Preinstalled on the github actions runner image: https://github.com/actions/runner-images/blob/ubuntu20/20221024.1/images/linux/Ubuntu2004-Readme.md

What steps did you perform?

  • Make a workflow for a github actions ubuntu-latest/20.04 run
  • Have a shellscript with the set -u flag enabled
  • Source nvm
  • Run nvm list
This fails

with-u-opt.sh

#! /bin/bash
set -u pipefail
source $HOME/.nvm/nvm.sh
nvm list
 -run: ./with-u-opt.sh
This works

without-u-opt.sh

#! /bin/bash
source $HOME/.nvm/nvm.sh
nvm list
 -run: ./without-u-opt.sh

What happened?

Example run from reproduction repo

/home/runner/.nvm/nvm.sh: line 1695: NVM_HAS_COLORS: unbound variable
Error: Process completed with exit code 1.

What did you expect to happen?

In v0.39.1 this error did not happen on the runner but after the latest image, which upgraded nvm to v0.39.2

I believe this has been the case since #2827 was merged

Reproduction repository:

https://github.com/jobackman/nvm-unbound-variable

Example run

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

Nope

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

@jobackman jobackman changed the title NVM_HAS_COLORS unbound variable in Github Actions Ubuntu NVM_HAS_COLORS unbound variable in shell scripts running in Github Actions Ubuntu images Oct 26, 2022
@ljharb
Copy link
Member

ljharb commented Oct 26, 2022

Thanks for the report.

@ljharb ljharb closed this as completed in 1f4bb91 Oct 26, 2022
@ljharb
Copy link
Member

ljharb commented Oct 26, 2022

I'll be releasing a v0.39.3 today, which will include this fix.

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

2 participants