As mentioned in https://github.com/creationix/nvm/issues/1102#issuecomment-250951849, when running nvm install (after sourcing the nvm.sh script with the --no-use flag) from a project with an .nvmrc file, I'm running into the nvm is not compatible with the npm config "prefix" option: currently set to "" error on a clean image unless a system node is available.
For context, this is for a docker image to be used as a Jenkins agent for building node projects. However, to distill it down a bit more, this is an alpine linux docker image based on openjdk:8-jdk-alpine with minimal additional installations, mostly dependencies of being a Jenkins agent.
No .npmrc is being added outside of the project being built by Jenkins and the .npmrc for the project only contains save-exact=true. Environment variables are only being set for Jenkins specific config and $NVM_DIR.
As soon as nodejs is added to the busybox apk add list, nvm install completes successfully without the prefix error, but this system level node installation should be unnecessary since nvm should be responsible for making node and npm available to the Jenkins build.
To make matters worse, the prefix failure from the nvm install command exits with a zero status code, so further commands chained with && are successfully triggered but fail because npm was not made available. This certainly complicated tracking down the problem because the prefix error appeared to only be a warning. If the prefix error is enough to not make npm or node available, the nvm install command should not exit with 0.
nvm install should return zero when it installs correctly - but I can see the logic in that if nvm use fails, the whole command should exit nonzero. That's one bug that can be easily fixed.
I see that your docker image is running the install script - after this runs, can you manually check the appropriate profile files (that hopefully docker is using with a login shell) for the appropriate nvm lines, and let me know what you find?
the image does not contain a profile file for the jenkins user that the build runs as. the warning suggesting manual addition is shown, but exits with a zero exit code. i think the zero exit is appropriate here since the message is more of a warning.
in our case, we set $NVM_DIR directly in the image and source the nvm.sh file (with the --no-use flag) as part of the build command at run time.
tl;dr: the lines are not added to a profile, but are handled (and work correctly when the nodejs package is included by apk)
Gotcha.
Can you get to a state where "nodejs" is not installed, and nvm use node fails with the prefix error, and provide the output of nvm debug and nvm use node --delete-prefix && nvm debug?
I have not tracked down the output that you asked for, but wanted to share something else that I realized.
This should probably have been obvious, but since the nvm install command exits with zero and the next step continues, I assumed that the presence of the system node allowed nvm to get past the prefix error. This assumption was not correct. nvm still fails to make the desired version of node/npm available, but the next command continues, using that system node installation.
You may have recognized this, but it did confuse me. Beyond getting us on the right track for the issue at hand, it does further highlight the need for that exit code to be non-zero.
I'm still working on getting to a state where I can get the other output. Stay tuned for that.
I'm trying to parse this out of Jenkins output, so hopefully i grabbed all the right pieces from nvm debug, but output from that command is below:
nvm --version: v0.32.0
$SHELL: /bin/false
$HOME: /home/jenkins
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
none
none
none
none
none
none
none
none
none
none
none
none
none
none
none
none
none
which node:
which iojs:
which npm:
npm config get prefix: $NVM_DIR/nvm.sh: line 2118: npm: command not found
npm root -g: $NVM_DIR/nvm.sh: line 2118: npm: command not found
full output
[TraviNodeJob] $ /bin/bash -xe /tmp/hudson5802565770963801218.sh
+ . /home/jenkins/.nvm/nvm.sh --no-use
++ NVM_SCRIPT_SOURCE=/bin/bash
++ '[' -z '' ']'
++ export NVM_CD_FLAGS=
++ NVM_CD_FLAGS=
++ nvm_has unsetopt
++ type unsetopt
++ '[' -z /home/jenkins/.nvm ']'
++ unset NVM_SCRIPT_SOURCE
++ '[' -z '' ']'
++ export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
++ NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
++ '[' -z '' ']'
++ export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
++ NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
++ nvm_process_parameters --no-use
++ local NVM_AUTO_MODE
++ NVM_AUTO_MODE=use
++ nvm_supports_source_options
+++ . /dev/stdin yes
+++ echo '[ $# -gt 0 ] && echo $1'
++ '[' _yes = _yes ']'
++ '[' 1 -ne 0 ']'
++ case "$1" in
++ NVM_AUTO_MODE=none
++ shift
++ '[' 0 -ne 0 ']'
++ nvm_auto none
++ local NVM_MODE
++ NVM_MODE=none
++ local VERSION
++ '[' _none = _install ']'
++ '[' _none = _use ']'
++ '[' _none '!=' _none ']'
+ nvm debug
+ '[' 1 -lt 1 ']'
+ local COMMAND
+ COMMAND=debug
+ shift
+ local VERSION
+ local ADDITIONAL_PARAMETERS
+ case $COMMAND in
+ local ZSH_HAS_SHWORDSPLIT_UNSET
+ ZSH_HAS_SHWORDSPLIT_UNSET=1
+ nvm_has setopt
+ type setopt
++ nvm --version
++ '[' 1 -lt 1 ']'
++ local COMMAND
++ COMMAND=--version
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_echo 0.32.0
++ command printf '%s\n' 0.32.0
+ nvm_err 'nvm --version: v0.32.0'
+ nvm_echo 'nvm --version: v0.32.0'
+ command printf '%s\n' 'nvm --version: v0.32.0'
nvm --version: v0.32.0
+ nvm_err '$SHELL: /bin/false'
+ nvm_echo '$SHELL: /bin/false'
+ command printf '%s\n' '$SHELL: /bin/false'
$SHELL: /bin/false
+ nvm_err '$HOME: /home/jenkins'
+ nvm_echo '$HOME: /home/jenkins'
+ command printf '%s\n' '$HOME: /home/jenkins'
$HOME: /home/jenkins
++ nvm_sanitize_path /home/jenkins/.nvm
++ local SANITIZED_PATH
++ SANITIZED_PATH=/home/jenkins/.nvm
++ '[' _/home/jenkins/.nvm '!=' _/home/jenkins/.nvm ']'
++ '[' _/home/jenkins/.nvm '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo /home/jenkins/.nvm
+++ command printf '%s\n' /home/jenkins/.nvm
++ SANITIZED_PATH='$HOME/.nvm'
++ nvm_echo '$HOME/.nvm'
++ command printf '%s\n' '$HOME/.nvm'
+ nvm_err '$NVM_DIR: '\''$HOME/.nvm'\'''
+ nvm_echo '$NVM_DIR: '\''$HOME/.nvm'\'''
+ command printf '%s\n' '$NVM_DIR: '\''$HOME/.nvm'\'''
$NVM_DIR: '$HOME/.nvm'
++ nvm_sanitize_path ''
++ local SANITIZED_PATH
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ nvm_echo ''
++ command printf '%s\n' ''
+ nvm_err '$PREFIX: '\'''\'''
+ nvm_echo '$PREFIX: '\'''\'''
+ command printf '%s\n' '$PREFIX: '\'''\'''
$PREFIX: ''
++ nvm_sanitize_path ''
++ local SANITIZED_PATH
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ nvm_echo ''
++ command printf '%s\n' ''
+ nvm_err '$NPM_CONFIG_PREFIX: '\'''\'''
+ nvm_echo '$NPM_CONFIG_PREFIX: '\'''\'''
+ command printf '%s\n' '$NPM_CONFIG_PREFIX: '\'''\'''
$NPM_CONFIG_PREFIX: ''
+ local NVM_DEBUG_OUTPUT
+ for NVM_DEBUG_COMMAND in ''\''nvm current'\''' ''\''which node'\''' ''\''which iojs'\''' ''\''which npm'\''' ''\''npm config get prefix'\''' ''\''npm root -g'\'''
++ nvm current
+ NVM_DEBUG_OUTPUT='++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ nvm_sanitize_path '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ local SANITIZED_PATH
++ SANITIZED_PATH='++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ '[' '_++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0' '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
+++ command printf '%s\n' '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ SANITIZED_PATH='++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ '[' '_++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0' '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
+++ command printf '%s\n' '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ SANITIZED_PATH='++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ nvm_echo '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
++ command printf '%s\n' '++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
+ nvm_err 'nvm current: ++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
+ nvm_echo 'nvm current: ++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
+ command printf '%s\n' 'nvm current: ++ '\''['\'' 1 -lt 1 '\'']'\''
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '\''['\'' -z current '\'']'\''
++ '\''['\'' current = current '\'']'\''
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '\''['\'' 1 -ne 0 '\'']'\''
++ nvm_echo none
++ command printf '\''%s\n'\'' none
none
++ return 0'
nvm current: ++ '[' 1 -lt 1 ']'
++ local COMMAND
++ COMMAND=current
++ shift
++ local VERSION
++ local ADDITIONAL_PARAMETERS
++ case $COMMAND in
++ nvm_version current
++ local PATTERN
++ PATTERN=current
++ local VERSION
++ '[' -z current ']'
++ '[' current = current ']'
++ nvm_ls_current
++ local NVM_LS_CURRENT_NODE_PATH
+++ command which node
++ NVM_LS_CURRENT_NODE_PATH=
++ '[' 1 -ne 0 ']'
++ nvm_echo none
++ command printf '%s\n' none
none
++ return 0
+ for NVM_DEBUG_COMMAND in ''\''nvm current'\''' ''\''which node'\''' ''\''which iojs'\''' ''\''which npm'\''' ''\''npm config get prefix'\''' ''\''npm root -g'\'''
++ which node
+ NVM_DEBUG_OUTPUT=
++ nvm_sanitize_path ''
++ local SANITIZED_PATH
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ nvm_echo ''
++ command printf '%s\n' ''
+ nvm_err 'which node: '
+ nvm_echo 'which node: '
+ command printf '%s\n' 'which node: '
which node:
+ for NVM_DEBUG_COMMAND in ''\''nvm current'\''' ''\''which node'\''' ''\''which iojs'\''' ''\''which npm'\''' ''\''npm config get prefix'\''' ''\''npm root -g'\'''
++ which iojs
+ NVM_DEBUG_OUTPUT=
++ nvm_sanitize_path ''
++ local SANITIZED_PATH
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ nvm_echo ''
++ command printf '%s\n' ''
+ nvm_err 'which iojs: '
+ nvm_echo 'which iojs: '
+ command printf '%s\n' 'which iojs: '
which iojs:
+ for NVM_DEBUG_COMMAND in ''\''nvm current'\''' ''\''which node'\''' ''\''which iojs'\''' ''\''which npm'\''' ''\''npm config get prefix'\''' ''\''npm root -g'\'''
++ which npm
+ NVM_DEBUG_OUTPUT=
++ nvm_sanitize_path ''
++ local SANITIZED_PATH
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ '[' _ '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo ''
+++ command printf '%s\n' ''
++ SANITIZED_PATH=
++ nvm_echo ''
++ command printf '%s\n' ''
+ nvm_err 'which npm: '
+ nvm_echo 'which npm: '
+ command printf '%s\n' 'which npm: '
which npm:
+ for NVM_DEBUG_COMMAND in ''\''nvm current'\''' ''\''which node'\''' ''\''which iojs'\''' ''\''which npm'\''' ''\''npm config get prefix'\''' ''\''npm root -g'\'''
++ npm config get prefix
+ NVM_DEBUG_OUTPUT='/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ nvm_sanitize_path '/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ local SANITIZED_PATH
++ SANITIZED_PATH='/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ '[' '_/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found' '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo '/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
+++ command printf '%s\n' '/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ SANITIZED_PATH='$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ '[' '_$NVM_DIR/nvm.sh: line 2118: npm: command not found' '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
+++ command printf '%s\n' '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ SANITIZED_PATH='$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ nvm_echo '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ command printf '%s\n' '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
+ nvm_err 'npm config get prefix: $NVM_DIR/nvm.sh: line 2118: npm: command not found'
+ nvm_echo 'npm config get prefix: $NVM_DIR/nvm.sh: line 2118: npm: command not found'
+ command printf '%s\n' 'npm config get prefix: $NVM_DIR/nvm.sh: line 2118: npm: command not found'
npm config get prefix: $NVM_DIR/nvm.sh: line 2118: npm: command not found
+ for NVM_DEBUG_COMMAND in ''\''nvm current'\''' ''\''which node'\''' ''\''which iojs'\''' ''\''which npm'\''' ''\''npm config get prefix'\''' ''\''npm root -g'\'''
++ npm root -g
+ NVM_DEBUG_OUTPUT='/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ nvm_sanitize_path '/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ local SANITIZED_PATH
++ SANITIZED_PATH='/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ '[' '_/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found' '!=' _/home/jenkins/.nvm ']'
+++ command sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ sed -e 's#/home/jenkins/.nvm#$NVM_DIR#g'
+++ nvm_echo '/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
+++ command printf '%s\n' '/home/jenkins/.nvm/nvm.sh: line 2118: npm: command not found'
++ SANITIZED_PATH='$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ '[' '_$NVM_DIR/nvm.sh: line 2118: npm: command not found' '!=' _/home/jenkins ']'
+++ command sed -e 's#/home/jenkins#$HOME#g'
+++ sed -e 's#/home/jenkins#$HOME#g'
+++ nvm_echo '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
+++ command printf '%s\n' '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ SANITIZED_PATH='$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ nvm_echo '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
++ command printf '%s\n' '$NVM_DIR/nvm.sh: line 2118: npm: command not found'
+ nvm_err 'npm root -g: $NVM_DIR/nvm.sh: line 2118: npm: command not found'
+ nvm_echo 'npm root -g: $NVM_DIR/nvm.sh: line 2118: npm: command not found'
+ command printf '%s\n' 'npm root -g: $NVM_DIR/nvm.sh: line 2118: npm: command not found'
npm root -g: $NVM_DIR/nvm.sh: line 2118: npm: command not found
+ '[' 1 -eq 1 ']'
+ nvm_has unsetopt
+ type unsetopt
+ return 42
Build step 'Execute shell' marked build as failure
it looks like this results in a 42 exit code due to npm not being available:
+ '[' 1 -eq 1 ']'
+ nvm_has unsetopt
+ type unsetopt
+ return 42
whoa, all the "none" lines are unexpected.
Also, why is $SHELL "/bin/false"?? Shouldn't it be bash, or sh, or something similar?
for nvm use node --delete-prefix, i'm seeing the following:
Because alpine linux is so stripped down, it looks like it does not support the q flag for ls
+++ ls -1qA /home/jenkins/.nvm
ls: unrecognized option: q
BusyBox v1.24.2 (2016-08-12 14:38:34 GMT) multi-call binary.
Usage: ls [-1AaCxdLHRFplinsehrSXvctu] [-w WIDTH] [FILE]...
List directory contents
-1 One column output
-a Include entries which start with .
-A Like -a, but exclude . and ..
-C List by columns
-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
-e List full date and time
-h List sizes in human readable format (1K 243M 2G)
-r Sort in reverse order
-S Sort by size
-X Sort by extension
-v Sort by version
-c With -l: sort by ctime
-t With -l: sort by mtime
-u With -l: sort by atime
-w N Assume the terminal is N columns wide
--color[={always,never,auto}] Control coloring
But, then it doesn't seem to understand node for use:
N/A: version "N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
full output
[TraviNodeJob] $ /bin/bash -xe /tmp/hudson4044828317493326932.sh
+ . /home/jenkins/.nvm/nvm.sh --no-use
++ NVM_SCRIPT_SOURCE=/bin/bash
++ '[' -z '' ']'
++ export NVM_CD_FLAGS=
++ NVM_CD_FLAGS=
++ nvm_has unsetopt
++ type unsetopt
++ '[' -z /home/jenkins/.nvm ']'
++ unset NVM_SCRIPT_SOURCE
++ '[' -z '' ']'
++ export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
++ NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
++ '[' -z '' ']'
++ export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
++ NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
++ nvm_process_parameters --no-use
++ local NVM_AUTO_MODE
++ NVM_AUTO_MODE=use
++ nvm_supports_source_options
+++ echo '[ $# -gt 0 ] && echo $1'
+++ . /dev/stdin yes
++ '[' _yes = _yes ']'
++ '[' 1 -ne 0 ']'
++ case "$1" in
++ NVM_AUTO_MODE=none
++ shift
++ '[' 0 -ne 0 ']'
++ nvm_auto none
++ local NVM_MODE
++ NVM_MODE=none
++ local VERSION
++ '[' _none = _install ']'
++ '[' _none = _use ']'
++ '[' _none '!=' _none ']'
+ nvm use node --delete-prefix
+ '[' 3 -lt 1 ']'
+ local COMMAND
+ COMMAND=use
+ shift
+ local VERSION
+ local ADDITIONAL_PARAMETERS
+ case $COMMAND in
+ local PROVIDED_VERSION
+ local NVM_USE_SILENT
+ NVM_USE_SILENT=0
+ local NVM_DELETE_PREFIX
+ NVM_DELETE_PREFIX=0
+ local NVM_LTS
+ '[' 2 -ne 0 ']'
+ case "$1" in
+ '[' -n node ']'
+ PROVIDED_VERSION=node
+ shift
+ '[' 1 -ne 0 ']'
+ case "$1" in
+ NVM_DELETE_PREFIX=1
+ shift
+ '[' 0 -ne 0 ']'
+ '[' -n '' ']'
+ '[' -z node ']'
++ nvm_match_version node
++ local NVM_IOJS_PREFIX
+++ nvm_iojs_prefix
+++ nvm_echo iojs
+++ command printf '%s\n' iojs
++ NVM_IOJS_PREFIX=iojs
++ local PROVIDED_VERSION
++ PROVIDED_VERSION=node
++ case "_$PROVIDED_VERSION" in
++ nvm_version node
++ local PATTERN
++ PATTERN=node
++ local VERSION
++ '[' -z node ']'
++ '[' node = current ']'
++ local NVM_NODE_PREFIX
+++ nvm_node_prefix
+++ nvm_echo node
+++ command printf '%s\n' node
++ NVM_NODE_PREFIX=node
++ case "_${PATTERN}" in
++ PATTERN=stable
+++ command tail -1
+++ tail -1
+++ nvm_ls stable
+++ local PATTERN
+++ PATTERN=stable
+++ local VERSIONS
+++ VERSIONS=
+++ '[' stable = current ']'
+++ local NVM_IOJS_PREFIX
++++ nvm_iojs_prefix
++++ nvm_echo iojs
++++ command printf '%s\n' iojs
+++ NVM_IOJS_PREFIX=iojs
+++ local NVM_NODE_PREFIX
++++ nvm_node_prefix
++++ nvm_echo node
++++ command printf '%s\n' node
+++ NVM_NODE_PREFIX=node
+++ local NVM_VERSION_DIR_IOJS
++++ nvm_version_dir iojs
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=iojs
++++ '[' -z iojs ']'
++++ '[' iojs = new ']'
++++ '[' _iojs = _iojs ']'
++++ nvm_echo /home/jenkins/.nvm/versions/io.js
++++ command printf '%s\n' /home/jenkins/.nvm/versions/io.js
+++ NVM_VERSION_DIR_IOJS=/home/jenkins/.nvm/versions/io.js
+++ local NVM_VERSION_DIR_NEW
++++ nvm_version_dir new
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=new
++++ '[' -z new ']'
++++ '[' new = new ']'
++++ nvm_echo /home/jenkins/.nvm/versions/node
++++ command printf '%s\n' /home/jenkins/.nvm/versions/node
+++ NVM_VERSION_DIR_NEW=/home/jenkins/.nvm/versions/node
+++ local NVM_VERSION_DIR_OLD
++++ nvm_version_dir old
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=old
++++ '[' -z old ']'
++++ '[' old = new ']'
++++ '[' _old = _iojs ']'
++++ '[' _old = _old ']'
++++ nvm_echo /home/jenkins/.nvm
++++ command printf '%s\n' /home/jenkins/.nvm
+++ NVM_VERSION_DIR_OLD=/home/jenkins/.nvm
+++ case "${PATTERN}" in
+++ nvm_resolve_local_alias stable
+++ '[' -z stable ']'
+++ local VERSION
+++ local EXIT_CODE
++++ nvm_resolve_alias stable
++++ '[' -z stable ']'
++++ local PATTERN
++++ PATTERN=stable
++++ local ALIAS
++++ ALIAS=stable
++++ local ALIAS_TEMP
++++ local SEEN_ALIASES
++++ SEEN_ALIASES=stable
++++ true
+++++ nvm_alias stable
+++++ echo
++++ ALIAS_TEMP=
++++ '[' -z '' ']'
++++ break
++++ '[' -n stable ']'
++++ '[' _stable '!=' _stable ']'
++++ nvm_validate_implicit_alias stable
++++ local IMPLICIT
+++++ nvm_print_implicit_alias local stable
++++ IMPLICIT=
++++ '[' -n '' ']'
++++ return 2
+++ VERSION=
+++ EXIT_CODE=2
+++ '[' -z '' ']'
+++ return 2
++++ nvm_ensure_version_prefix stable
++++ local NVM_VERSION
+++++ command sed -e 's/^\([0-9]\)/v\1/g'
+++++ sed -e 's/^\([0-9]\)/v\1/g'
+++++ nvm_strip_iojs_prefix stable
+++++ local NVM_IOJS_PREFIX
++++++ nvm_iojs_prefix
++++++ nvm_echo iojs
++++++ command printf '%s\n' iojs
+++++ NVM_IOJS_PREFIX=iojs
+++++ '[' stable = iojs ']'
+++++ nvm_echo stable
+++++ command printf '%s\n' stable
++++ NVM_VERSION=stable
++++ nvm_is_iojs_version stable
++++ case "${1-}" in
++++ return 1
++++ nvm_echo stable
++++ command printf '%s\n' stable
+++ PATTERN=stable
+++ '[' stable = N/A ']'
+++ local NVM_PATTERN_STARTS_WITH_V
+++ case $PATTERN in
+++ NVM_PATTERN_STARTS_WITH_V=false
+++ '[' false = true ']'
+++ case "${PATTERN}" in
+++ local NUM_VERSION_GROUPS
++++ nvm_num_version_groups stable
++++ local VERSION
++++ VERSION=stable
++++ VERSION=stable
++++ VERSION=stable
++++ '[' -z stable ']'
++++ local NVM_NUM_DOTS
+++++ command sed -e 's/[^\.]//g'
+++++ sed -e 's/[^\.]//g'
+++++ nvm_echo stable
+++++ command printf '%s\n' stable
++++ NVM_NUM_DOTS=
++++ local NVM_NUM_GROUPS
++++ NVM_NUM_GROUPS=.
++++ nvm_echo 1
++++ command printf '%s\n' 1
+++ NUM_VERSION_GROUPS=1
+++ '[' 1 = 2 ']'
+++ '[' 1 = 1 ']'
+++ PATTERN=stable.
+++ local ZSH_HAS_SHWORDSPLIT_UNSET
+++ ZSH_HAS_SHWORDSPLIT_UNSET=1
+++ nvm_has setopt
+++ type setopt
+++ local NVM_DIRS_TO_SEARCH1
+++ NVM_DIRS_TO_SEARCH1=
+++ local NVM_DIRS_TO_SEARCH2
+++ NVM_DIRS_TO_SEARCH2=
+++ local NVM_DIRS_TO_SEARCH3
+++ NVM_DIRS_TO_SEARCH3=
+++ local NVM_ADD_SYSTEM
+++ NVM_ADD_SYSTEM=false
+++ nvm_is_iojs_version stable.
+++ case "${1-}" in
+++ return 1
+++ '[' stable. = node- ']'
+++ NVM_DIRS_TO_SEARCH1=/home/jenkins/.nvm
+++ NVM_DIRS_TO_SEARCH2=/home/jenkins/.nvm/versions/node
+++ NVM_DIRS_TO_SEARCH3=/home/jenkins/.nvm/versions/io.js
+++ nvm_has_system_iojs
++++ nvm deactivate
++++ command -v iojs
+++ '[' '' '!=' '' ']'
+++ nvm_has_system_node
++++ nvm deactivate
++++ command -v node
+++ '[' '' '!=' '' ']'
+++ '[' -d /home/jenkins/.nvm ']'
+++ nvm_grep -q .
+++ GREP_OPTIONS=
+++ command grep -q .
+++ grep -q .
+++ command ls -1qA /home/jenkins/.nvm
+++ ls -1qA /home/jenkins/.nvm
ls: unrecognized option: q
BusyBox v1.24.2 (2016-08-12 14:38:34 GMT) multi-call binary.
Usage: ls [-1AaCxdLHRFplinsehrSXvctu] [-w WIDTH] [FILE]...
List directory contents
-1 One column output
-a Include entries which start with .
-A Like -a, but exclude . and ..
-C List by columns
-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
-e List full date and time
-h List sizes in human readable format (1K 243M 2G)
-r Sort in reverse order
-S Sort by size
-X Sort by extension
-v Sort by version
-c With -l: sort by ctime
-t With -l: sort by mtime
-u With -l: sort by atime
-w N Assume the terminal is N columns wide
--color[={always,never,auto}] Control coloring
+++ NVM_DIRS_TO_SEARCH1=
+++ '[' -d /home/jenkins/.nvm/versions/node ']'
+++ NVM_DIRS_TO_SEARCH2=
+++ '[' -d /home/jenkins/.nvm/versions/io.js ']'
+++ NVM_DIRS_TO_SEARCH3=
+++ local SEARCH_PATTERN
+++ '[' -z stable. ']'
++++ sed 's#\.#\\.#g;'
++++ echo stable.
+++ SEARCH_PATTERN='stable\.'
+++ '[' -n '' ']'
+++ '[' 1 -eq 1 ']'
+++ nvm_has unsetopt
+++ type unsetopt
+++ '[' false = true ']'
+++ '[' -z '' ']'
+++ nvm_echo N/A
+++ command printf '%s\n' N/A
+++ return 3
++ VERSION=N/A
++ '[' -z N/A ']'
++ '[' _N/A = _N/A ']'
++ nvm_echo N/A
++ command printf '%s\n' N/A
++ return 3
+ VERSION=N/A
+ '[' -z N/A ']'
+ '[' _N/A = _system ']'
+ '[' _N/A = _∞ ']'
+ nvm_ensure_version_installed N/A
+ local PROVIDED_VERSION
+ PROVIDED_VERSION=N/A
+ local LOCAL_VERSION
+ local EXIT_CODE
++ nvm_version N/A
++ local PATTERN
++ PATTERN=N/A
++ local VERSION
++ '[' -z N/A ']'
++ '[' N/A = current ']'
++ local NVM_NODE_PREFIX
+++ nvm_node_prefix
+++ nvm_echo node
+++ command printf '%s\n' node
++ NVM_NODE_PREFIX=node
++ case "_${PATTERN}" in
+++ command tail -1
+++ tail -1
+++ nvm_ls N/A
+++ local PATTERN
+++ PATTERN=N/A
+++ local VERSIONS
+++ VERSIONS=
+++ '[' N/A = current ']'
+++ local NVM_IOJS_PREFIX
++++ nvm_iojs_prefix
++++ nvm_echo iojs
++++ command printf '%s\n' iojs
+++ NVM_IOJS_PREFIX=iojs
+++ local NVM_NODE_PREFIX
++++ nvm_node_prefix
++++ nvm_echo node
++++ command printf '%s\n' node
+++ NVM_NODE_PREFIX=node
+++ local NVM_VERSION_DIR_IOJS
++++ nvm_version_dir iojs
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=iojs
++++ '[' -z iojs ']'
++++ '[' iojs = new ']'
++++ '[' _iojs = _iojs ']'
++++ nvm_echo /home/jenkins/.nvm/versions/io.js
++++ command printf '%s\n' /home/jenkins/.nvm/versions/io.js
+++ NVM_VERSION_DIR_IOJS=/home/jenkins/.nvm/versions/io.js
+++ local NVM_VERSION_DIR_NEW
++++ nvm_version_dir new
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=new
++++ '[' -z new ']'
++++ '[' new = new ']'
++++ nvm_echo /home/jenkins/.nvm/versions/node
++++ command printf '%s\n' /home/jenkins/.nvm/versions/node
+++ NVM_VERSION_DIR_NEW=/home/jenkins/.nvm/versions/node
+++ local NVM_VERSION_DIR_OLD
++++ nvm_version_dir old
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=old
++++ '[' -z old ']'
++++ '[' old = new ']'
++++ '[' _old = _iojs ']'
++++ '[' _old = _old ']'
++++ nvm_echo /home/jenkins/.nvm
++++ command printf '%s\n' /home/jenkins/.nvm
+++ NVM_VERSION_DIR_OLD=/home/jenkins/.nvm
+++ case "${PATTERN}" in
+++ nvm_resolve_local_alias N/A
+++ '[' -z N/A ']'
+++ local VERSION
+++ local EXIT_CODE
++++ nvm_resolve_alias N/A
++++ '[' -z N/A ']'
++++ local PATTERN
++++ PATTERN=N/A
++++ local ALIAS
++++ ALIAS=N/A
++++ local ALIAS_TEMP
++++ local SEEN_ALIASES
++++ SEEN_ALIASES=N/A
++++ true
+++++ nvm_alias N/A
+++++ echo
++++ ALIAS_TEMP=
++++ '[' -z '' ']'
++++ break
++++ '[' -n N/A ']'
++++ '[' _N/A '!=' _N/A ']'
++++ nvm_validate_implicit_alias N/A
++++ return 2
+++ VERSION=
+++ EXIT_CODE=2
+++ '[' -z '' ']'
+++ return 2
++++ nvm_ensure_version_prefix N/A
++++ local NVM_VERSION
+++++ command sed -e 's/^\([0-9]\)/v\1/g'
+++++ sed -e 's/^\([0-9]\)/v\1/g'
+++++ nvm_strip_iojs_prefix N/A
+++++ local NVM_IOJS_PREFIX
++++++ nvm_iojs_prefix
++++++ nvm_echo iojs
++++++ command printf '%s\n' iojs
+++++ NVM_IOJS_PREFIX=iojs
+++++ '[' N/A = iojs ']'
+++++ nvm_echo N/A
+++++ command printf '%s\n' N/A
++++ NVM_VERSION=N/A
++++ nvm_is_iojs_version N/A
++++ case "${1-}" in
++++ return 1
++++ nvm_echo N/A
++++ command printf '%s\n' N/A
+++ PATTERN=N/A
+++ '[' N/A = N/A ']'
+++ return
++ VERSION=
++ '[' -z '' ']'
++ nvm_echo N/A
++ command printf '%s\n' N/A
++ return 3
+ LOCAL_VERSION=N/A
+ EXIT_CODE=3
+ local NVM_VERSION_DIR
+ '[' 3 '!=' 0 ']'
++ nvm_resolve_alias N/A
++ '[' -z N/A ']'
++ local PATTERN
++ PATTERN=N/A
++ local ALIAS
++ ALIAS=N/A
++ local ALIAS_TEMP
++ local SEEN_ALIASES
++ SEEN_ALIASES=N/A
++ true
+++ nvm_alias N/A
+++ echo
++ ALIAS_TEMP=
++ '[' -z '' ']'
++ break
++ '[' -n N/A ']'
++ '[' _N/A '!=' _N/A ']'
++ nvm_validate_implicit_alias N/A
++ return 2
+ VERSION=
+ '[' 2 -eq 0 ']'
+ local PREFIXED_VERSION
++ nvm_ensure_version_prefix N/A
++ local NVM_VERSION
+++ command sed -e 's/^\([0-9]\)/v\1/g'+++ nvm_strip_iojs_prefix N/A
+++ local NVM_IOJS_PREFIX
++++ nvm_iojs_prefix
++++ nvm_echo iojs
++++ command printf '%s\n' iojs
+++ NVM_IOJS_PREFIX=iojs
+++ '[' N/A = iojs ']'
+++ nvm_echo N/A
+++ command printf '%s\n' N/A
+++ sed -e 's/^\([0-9]\)/v\1/g'
++ NVM_VERSION=N/A
++ nvm_is_iojs_version N/A
++ case "${1-}" in
++ return 1
++ nvm_echo N/A
++ command printf '%s\n' N/A
+ PREFIXED_VERSION=N/A
+ nvm_err 'N/A: version "N/A" is not yet installed.'
+ nvm_echo 'N/A: version "N/A" is not yet installed.'
+ command printf '%s\n' 'N/A: version "N/A" is not yet installed.'
N/A: version "N/A" is not yet installed.
+ nvm_err ''
+ nvm_echo ''
+ command printf '%s\n' ''
+ nvm_err 'You need to run "nvm install N/A" to install it before using it.'
+ nvm_echo 'You need to run "nvm install N/A" to install it before using it.'
+ command printf '%s\n' 'You need to run "nvm install N/A" to install it before using it.'
You need to run "nvm install N/A" to install it before using it.
+ return 1
+ EXIT_CODE=1
+ '[' 1 '!=' 0 ']'
-q is part of posix - if alpine linux deviates from POSIX than nvm won't work on it.
If nvm_ls doesn't work because ls isn't working properly, then certainly it won't be able to resolve "node" to a specific version number :-/
I've added the full output above for the nvm debug command in case it explains anything about the none lines or anything else. The lines w/o the +s are what I believe to be the actual output, but can't be sure if that is always the case.
also added the full output for the nvm use node --delete-prefix build
i was able to add the coreutils package to the alpine image to make a POSIX compliant ls available, but the other messages remain:
N/A: version "N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
I saw that you asked about $SHELL. Jenkins does not use an interactive login shell, so that would not end up getting set. However, if you look at the first line of the full output, it uses /bin/bash to run the script that defines the build steps.
I think the question that I have that seems more related is "why is $PREFIX set to ''"?
Yes, that's a good question. If you env | grep -i prefix, what shows up?
prefix is not in the env output at all
ok, what does nvm version node and set -x ; nvm use node print out?
nvm version node = N/A
set -x ; nvm use node:
output
+ '[' 2 -lt 1 ']'
+ local COMMAND
+ COMMAND=use
+ shift
+ local VERSION
+ local ADDITIONAL_PARAMETERS
+ case $COMMAND in
+ local PROVIDED_VERSION
+ local NVM_USE_SILENT
+ NVM_USE_SILENT=0
+ local NVM_DELETE_PREFIX
+ NVM_DELETE_PREFIX=0
+ local NVM_LTS
+ '[' 1 -ne 0 ']'
+ case "$1" in
+ '[' -n node ']'
+ PROVIDED_VERSION=node
+ shift
+ '[' 0 -ne 0 ']'
+ '[' -n '' ']'
+ '[' -z node ']'
++ nvm_match_version node
++ local NVM_IOJS_PREFIX
+++ nvm_iojs_prefix
+++ nvm_echo iojs
+++ command printf '%s\n' iojs
++ NVM_IOJS_PREFIX=iojs
++ local PROVIDED_VERSION
++ PROVIDED_VERSION=node
++ case "_$PROVIDED_VERSION" in
++ nvm_version node
++ local PATTERN
++ PATTERN=node
++ local VERSION
++ '[' -z node ']'
++ '[' node = current ']'
++ local NVM_NODE_PREFIX
+++ nvm_node_prefix
+++ nvm_echo node
+++ command printf '%s\n' node
++ NVM_NODE_PREFIX=node
++ case "_${PATTERN}" in
++ PATTERN=stable
+++ command tail -1
+++ tail -1
+++ nvm_ls stable
+++ local PATTERN
+++ PATTERN=stable
+++ local VERSIONS
+++ VERSIONS=
+++ '[' stable = current ']'
+++ local NVM_IOJS_PREFIX
++++ nvm_iojs_prefix
++++ nvm_echo iojs
++++ command printf '%s\n' iojs
+++ NVM_IOJS_PREFIX=iojs
+++ local NVM_NODE_PREFIX
++++ nvm_node_prefix
++++ nvm_echo node
++++ command printf '%s\n' node
+++ NVM_NODE_PREFIX=node
+++ local NVM_VERSION_DIR_IOJS
++++ nvm_version_dir iojs
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=iojs
++++ '[' -z iojs ']'
++++ '[' iojs = new ']'
++++ '[' _iojs = _iojs ']'
++++ nvm_echo /home/jenkins/.nvm/versions/io.js
++++ command printf '%s\n' /home/jenkins/.nvm/versions/io.js
+++ NVM_VERSION_DIR_IOJS=/home/jenkins/.nvm/versions/io.js
+++ local NVM_VERSION_DIR_NEW
++++ nvm_version_dir new
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=new
++++ '[' -z new ']'
++++ '[' new = new ']'
++++ nvm_echo /home/jenkins/.nvm/versions/node
++++ command printf '%s\n' /home/jenkins/.nvm/versions/node
+++ NVM_VERSION_DIR_NEW=/home/jenkins/.nvm/versions/node
+++ local NVM_VERSION_DIR_OLD
++++ nvm_version_dir old
++++ local NVM_WHICH_DIR
++++ NVM_WHICH_DIR=old
++++ '[' -z old ']'
++++ '[' old = new ']'
++++ '[' _old = _iojs ']'
++++ '[' _old = _old ']'
++++ nvm_echo /home/jenkins/.nvm
++++ command printf '%s\n' /home/jenkins/.nvm
+++ NVM_VERSION_DIR_OLD=/home/jenkins/.nvm
+++ case "${PATTERN}" in
+++ nvm_resolve_local_alias stable
+++ '[' -z stable ']'
+++ local VERSION
+++ local EXIT_CODE
++++ nvm_resolve_alias stable
++++ '[' -z stable ']'
++++ local PATTERN
++++ PATTERN=stable
++++ local ALIAS
++++ ALIAS=stable
++++ local ALIAS_TEMP
++++ local SEEN_ALIASES
++++ SEEN_ALIASES=stable
++++ true
+++++ nvm_alias stable
+++++ echo
++++ ALIAS_TEMP=
++++ '[' -z '' ']'
++++ break
++++ '[' -n stable ']'
++++ '[' _stable '!=' _stable ']'
++++ nvm_validate_implicit_alias stable
++++ local IMPLICIT
+++++ nvm_print_implicit_alias local stable
++++ IMPLICIT=
++++ '[' -n '' ']'
++++ return 2
+++ VERSION=
+++ EXIT_CODE=2
+++ '[' -z '' ']'
+++ return 2
++++ nvm_ensure_version_prefix stable
++++ local NVM_VERSION
+++++ command sed -e 's/^\([0-9]\)/v\1/g'
+++++ sed -e 's/^\([0-9]\)/v\1/g'
+++++ nvm_strip_iojs_prefix stable
+++++ local NVM_IOJS_PREFIX
++++++ nvm_iojs_prefix
++++++ nvm_echo iojs
++++++ command printf '%s\n' iojs
+++++ NVM_IOJS_PREFIX=iojs
+++++ '[' stable = iojs ']'
+++++ nvm_echo stable
+++++ command printf '%s\n' stable
++++ NVM_VERSION=stable
++++ nvm_is_iojs_version stable
++++ case "${1-}" in
++++ return 1
++++ nvm_echo stable
++++ command printf '%s\n' stable
+++ PATTERN=stable
+++ '[' stable = N/A ']'
+++ local NVM_PATTERN_STARTS_WITH_V
+++ case $PATTERN in
+++ NVM_PATTERN_STARTS_WITH_V=false
+++ '[' false = true ']'
+++ case "${PATTERN}" in
+++ local NUM_VERSION_GROUPS
++++ nvm_num_version_groups stable
++++ local VERSION
++++ VERSION=stable
++++ VERSION=stable
++++ VERSION=stable
++++ '[' -z stable ']'
++++ local NVM_NUM_DOTS
+++++ command sed -e 's/[^\.]//g'
+++++ sed -e 's/[^\.]//g'
+++++ nvm_echo stable
+++++ command printf '%s\n' stable
++++ NVM_NUM_DOTS=
++++ local NVM_NUM_GROUPS
++++ NVM_NUM_GROUPS=.
++++ nvm_echo 1
++++ command printf '%s\n' 1
+++ NUM_VERSION_GROUPS=1
+++ '[' 1 = 2 ']'
+++ '[' 1 = 1 ']'
+++ PATTERN=stable.
+++ local ZSH_HAS_SHWORDSPLIT_UNSET
+++ ZSH_HAS_SHWORDSPLIT_UNSET=1
+++ nvm_has setopt
+++ type setopt
+++ local NVM_DIRS_TO_SEARCH1
+++ NVM_DIRS_TO_SEARCH1=
+++ local NVM_DIRS_TO_SEARCH2
+++ NVM_DIRS_TO_SEARCH2=
+++ local NVM_DIRS_TO_SEARCH3
+++ NVM_DIRS_TO_SEARCH3=
+++ local NVM_ADD_SYSTEM
+++ NVM_ADD_SYSTEM=false
+++ nvm_is_iojs_version stable.
+++ case "${1-}" in
+++ return 1
+++ '[' stable. = node- ']'
+++ NVM_DIRS_TO_SEARCH1=/home/jenkins/.nvm
+++ NVM_DIRS_TO_SEARCH2=/home/jenkins/.nvm/versions/node
+++ NVM_DIRS_TO_SEARCH3=/home/jenkins/.nvm/versions/io.js
+++ nvm_has_system_iojs
++++ nvm deactivate
++++ command -v iojs
+++ '[' '' '!=' '' ']'
+++ nvm_has_system_node
++++ nvm deactivate
++++ command -v node
+++ '[' '' '!=' '' ']'
+++ '[' -d /home/jenkins/.nvm ']'
+++ nvm_grep -q .
+++ GREP_OPTIONS=
+++ command grep -q .
+++ grep -q .
+++ command ls -1qA /home/jenkins/.nvm
+++ ls -1qA /home/jenkins/.nvm
+++ '[' -d /home/jenkins/.nvm/versions/node ']'
+++ NVM_DIRS_TO_SEARCH2=/home/jenkins/.nvm
+++ '[' -d /home/jenkins/.nvm/versions/io.js ']'
+++ NVM_DIRS_TO_SEARCH3=/home/jenkins/.nvm
+++ local SEARCH_PATTERN
+++ '[' -z stable. ']'
++++ sed 's#\.#\\.#g;'
++++ echo stable.
+++ SEARCH_PATTERN='stable\.'
+++ '[' -n /home/jenkins/.nvm/home/jenkins/.nvm/home/jenkins/.nvm ']'
++++ ++++ command sed '
s#\(.*\)\.\([^\.]\{1,\}\)$#\2-\1#;
s#^node-##;
'
++++ sed '
s#\(.*\)\.\([^\.]\{1,\}\)$#\2-\1#;
s#^node-##;
'
command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n
++++ sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n
++++ command sed 's#^\([^/]\{1,\}\)/\(.*\)$#\2.\1#;'
++++ sed 's#^\([^/]\{1,\}\)/\(.*\)$#\2.\1#;'
++++ command sed '
s#/home/jenkins/.nvm/versions/io.js/#versions/iojs/#;
s#^/home/jenkins/.nvm/##;
\#^[^v]# d;
\#^versions$# d;
s#^versions/##;
s#^v#node/v#;
\#stable\.# !d;
'
++++ sed '
s#/home/jenkins/.nvm/versions/io.js/#versions/iojs/#;
s#^/home/jenkins/.nvm/##;
\#^[^v]# d;
\#^versions$# d;
s#^versions/##;
s#^v#node/v#;
\#stable\.# !d;
'
++++ command find /home/jenkins/.nvm/CONTRIBUTING.md /home/jenkins/.nvm/LICENSE.md /home/jenkins/.nvm/Makefile /home/jenkins/.nvm/README.markdown /home/jenkins/.nvm/ROADMAP.md /home/jenkins/.nvm/bash_completion /home/jenkins/.nvm/install.sh /home/jenkins/.nvm/nvm-exec /home/jenkins/.nvm/nvm.sh /home/jenkins/.nvm/package.json /home/jenkins/.nvm/test /home/jenkins/.nvm/update_test_mocks.sh /home/jenkins/.nvm/CONTRIBUTING.md /home/jenkins/.nvm/LICENSE.md /home/jenkins/.nvm/Makefile /home/jenkins/.nvm/README.markdown /home/jenkins/.nvm/ROADMAP.md /home/jenkins/.nvm/bash_completion /home/jenkins/.nvm/install.sh /home/jenkins/.nvm/nvm-exec /home/jenkins/.nvm/nvm.sh /home/jenkins/.nvm/package.json /home/jenkins/.nvm/test /home/jenkins/.nvm/update_test_mocks.sh /home/jenkins/.nvm/CONTRIBUTING.md /home/jenkins/.nvm/LICENSE.md /home/jenkins/.nvm/Makefile /home/jenkins/.nvm/README.markdown /home/jenkins/.nvm/ROADMAP.md /home/jenkins/.nvm/bash_completion /home/jenkins/.nvm/install.sh /home/jenkins/.nvm/nvm-exec /home/jenkins/.nvm/nvm.sh /home/jenkins/.nvm/package.json /home/jenkins/.nvm/test /home/jenkins/.nvm/update_test_mocks.sh -name . -o -type d -prune -o -path 'stable.*'
++++ find /home/jenkins/.nvm/CONTRIBUTING.md /home/jenkins/.nvm/LICENSE.md /home/jenkins/.nvm/Makefile /home/jenkins/.nvm/README.markdown /home/jenkins/.nvm/ROADMAP.md /home/jenkins/.nvm/bash_completion /home/jenkins/.nvm/install.sh /home/jenkins/.nvm/nvm-exec /home/jenkins/.nvm/nvm.sh /home/jenkins/.nvm/package.json /home/jenkins/.nvm/test /home/jenkins/.nvm/update_test_mocks.sh /home/jenkins/.nvm/CONTRIBUTING.md /home/jenkins/.nvm/LICENSE.md /home/jenkins/.nvm/Makefile /home/jenkins/.nvm/README.markdown /home/jenkins/.nvm/ROADMAP.md /home/jenkins/.nvm/bash_completion /home/jenkins/.nvm/install.sh /home/jenkins/.nvm/nvm-exec /home/jenkins/.nvm/nvm.sh /home/jenkins/.nvm/package.json /home/jenkins/.nvm/test /home/jenkins/.nvm/update_test_mocks.sh /home/jenkins/.nvm/CONTRIBUTING.md /home/jenkins/.nvm/LICENSE.md /home/jenkins/.nvm/Makefile /home/jenkins/.nvm/README.markdown /home/jenkins/.nvm/ROADMAP.md /home/jenkins/.nvm/bash_completion /home/jenkins/.nvm/install.sh /home/jenkins/.nvm/nvm-exec /home/jenkins/.nvm/nvm.sh /home/jenkins/.nvm/package.json /home/jenkins/.nvm/test /home/jenkins/.nvm/update_test_mocks.sh -name . -o -type d -prune -o -path 'stable.*'
+++ VERSIONS=
+++ '[' 1 -eq 1 ']'
+++ nvm_has unsetopt
+++ type unsetopt
+++ '[' false = true ']'
+++ '[' -z '' ']'
+++ nvm_echo N/A
+++ command printf '%s\n' N/A
+++ return 3
++ VERSION=N/A
++ '[' -z N/A ']'
++ '[' _N/A = _N/A ']'
++ nvm_echo N/A
++ command printf '%s\n' N/A
++ return 3
+ VERSION=N/A
any further thoughts from the latest output above?
Yes - it looks like [' -d /home/jenkins/.nvm/versions/node ']' is failing, which indicates that there's no node versions installed. If you cd $NVM_DIR, is there a "versions" directory? if so, what's inside it?
+ ls -la /home/jenkins/.nvm/versions/node
ls: cannot access '/home/jenkins/.nvm/versions/node': No such file or directory
+ ls -la /home/jenkins/.nvm
total 196
drwxr-sr-x 4 jenkins nogroup 4096 Oct 4 18:13 .
drwxr-sr-x 5 jenkins nogroup 4096 Oct 6 16:32 ..
drwxr-sr-x 8 jenkins nogroup 4096 Oct 4 18:13 .git
-rw-r--r-- 1 jenkins nogroup 12 Oct 4 18:13 .gitattributes
-rw-r--r-- 1 jenkins nogroup 140 Oct 4 18:13 .gitignore
-rw-r--r-- 1 jenkins nogroup 14 Oct 4 18:13 .npmignore
-rw-r--r-- 1 jenkins nogroup 3136 Oct 4 18:13 .travis.yml
-rw-r--r-- 1 jenkins nogroup 763 Oct 4 18:13 CONTRIBUTING.md
-rw-r--r-- 1 jenkins nogroup 1084 Oct 4 18:13 LICENSE.md
-rw-r--r-- 1 jenkins nogroup 5212 Oct 4 18:13 Makefile
-rw-r--r-- 1 jenkins nogroup 18729 Oct 4 18:13 README.markdown
-rw-r--r-- 1 jenkins nogroup 908 Oct 4 18:13 ROADMAP.md
-rw-r--r-- 1 jenkins nogroup 1898 Oct 4 18:13 bash_completion
-rwxr-xr-x 1 jenkins nogroup 10007 Oct 4 18:13 install.sh
-rwxr-xr-x 1 jenkins nogroup 313 Oct 4 18:13 nvm-exec
-rw-r--r-- 1 jenkins nogroup 95486 Oct 4 18:13 nvm.sh
-rw-r--r-- 1 jenkins nogroup 1749 Oct 4 18:13 package.json
drwxr-sr-x 9 jenkins nogroup 4096 Oct 4 18:13 test
-rwxr-xr-x 1 jenkins nogroup 1228 Oct 4 18:13 update_test_mocks.sh
keep in mind that each time I run these commands, it creates a new container instance, so previous commands have not had any effect. which command would you expect to create these directories?
Sorry for the miscommunication. nvm install node should create them. I'm looking for the output of nvm install node ; nvm version node ; set -x ; nvm use node
Theres a lot here, so hopefully some of it will be helpful (too long to include directly in the comment, so included as a file):
ok so…
the original prefix error might be related to:
++ npm config get prefix
/usr/bin/env: ‘node’: No such file or directory
which is here. the $PATH should allow node to be found, which should be set here. However, scrolling up in the output a bit, I see:
++ type npm
+++ npm --version
++ command printf ' (npm v)'
++ printf ' (npm v)'
+ NVM_USE_OUTPUT='Now using node v6.7.0 (npm v)'
… in other words, npm was present, but npm --version printed out an empty string (this is weird).
nvm version node worked fine, printing out v6.7.0 - which indicates that it was successfully installed (even though the implicit nvm use command had failed due to a failure in nvm_die_on_prefix, described above).
now for set -x ; nvm use node:
I see the same failure(s) I described in the first section here.
+ PATH=/home/jenkins/.nvm/versions/node/v6.7.0/bin:/usr/lib/jvm/java-1.8.0-openjdk/bin:/usr/local/sbt/bin:/etc/alternatives/java_sdk_1.8.0/bin:/var/lib/jenkins/.rvm/gems/ruby-2.1.5/bin:/var/lib/jenkins/.rvm/gems/ruby-2.1.5@global/bin:/var/lib/jenkins/.rvm/rubies/ruby-2.1.5/bin:/var/lib/jenkins/.rvm/bin:/usr/local/share:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+ export PATH
^ the above should ensure that /home/jenkins/.nvm/versions/node/v6.7.0/bin is checked first, and if you cd into that directory (in a container that has had nvm install node ran, ofc), you should see both node and npm in there. If so, can you run set +x; ls; which npm; ./npm --version and provide the output?
+ ls /home/jenkins/.nvm/versions/node/v6.7.0/bin
node
npm
+ /home/jenkins/.nvm/versions/node/v6.7.0/bin/npm --version
/usr/bin/env: ‘node’: No such file or directory
it looks like since npm can't find node on the $PATH, it fails. i did not run the which command that you asked for because it is tough to get into that context from a jenkins script, but i would also expect it to fail since it doesn't look like the current directory is included in the path.
i take it back, i was able to get the script to change directories successfully, but it confirmed that which npm failed.
OK, If you then run PATH=/home/jenkins/.nvm/versions/node/v6.7.0/bin:$PATH npm --version, what happens?
solved the issue, but by swapping an alpine linux base for a debian base.
the reason for the switch was due to digging into why npm --version and other npm commands kept failing with /usr/bin/env: ‘node’: No such file or directory.
$ head `which npm`
#!/usr/bin/env node
since npm sets a node shebang, it obviously needs to have node available. it would make sense for this to be as a result of node not being on the $PATH, which is why I agreed with the "weird"ness of the observations in the output above. however, it ended up not being a $PATH problem.
it turns out that node not being available was instead a result of symbols not being available to node:
+ ldd /home/jenkins/.nvm/versions/node/v6.7.0/bin/node
/lib64/ld-linux-x86-64.so.2 (0x5596014dd000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x5596014dd000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x5596014dd000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f3cc3f50000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x5596014dd000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f3cc3d3d000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x5596014dd000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x5596014dd000)
Error relocating /home/jenkins/.nvm/versions/node/v6.7.0/bin/node: __isinf: symbol not found
Error relocating /home/jenkins/.nvm/versions/node/v6.7.0/bin/node: __isnan: symbol not found
Error relocating /home/jenkins/.nvm/versions/node/v6.7.0/bin/node: __strtod_internal: symbol not found
Error relocating /home/jenkins/.nvm/versions/node/v6.7.0/bin/node: backtrace: symbol not found
this is because alpine apparently uses musl as libc instead of the traditional glibc.
glibc can be installed on alpine, but starts to deviate from the reason we were using alpine in the first place. this, plus the fact that we were needing to install the more standard packages for things like coreutils, tar, make, g++, etc caused us to decide it simply made more sense to start with a debian base image.
while i'm moving away from using alpine, i think this effort did expose a couple of things that are worth influencing enhancements of nvm. the first is the exit code mentioned early on in the thread. the other would be a check for the presence of glibc rather than something else, like musl and failing early with a clear message, especially since the resulting failure doesn't show the absence of the necessary symbols without ldd.
Thanks, that's very helpful! I'll leave this open until those have been investigated and/or addressed. Glad you got it working :-)
Sure thing. Hopefully some of this will help the next guy at least :)
Thanks for the help along the way.
Closing for now; will leave the "info" tag on it.
Most helpful comment
Sure thing. Hopefully some of this will help the next guy at least :)
Thanks for the help along the way.