Fabric + Virtualenvwrapper gives fatal error: run() received nonzero return code 1 while executing - return

I have a fabric script to use virtualenvwrapper to create virtualenv, but after running mkvirutalenv the fabric script complains about return code, see below
[localhost] run: export WORKON_HOME=/srv/www && source /usr/local/bin/virtualenvwrapper.sh && mkvirtualenv james --no-site-packages --distribute
[localhost] Login password for 'james':
[localhost] out: New python executable in james/bin/python
[localhost] out: Installing distribute...........................................................................................................................................................................................................................done.
[localhost] out: Installing pip................done.
Fatal error: run() received nonzero return code 1 while executing!
Requested: export WORKON_HOME=/srv/www && source /usr/local/bin/virtualenvwrapper.sh && mkvirtualenv james --no-site-packages --distribute
Executed: /bin/bash -l -c "cd /srv/www && export WORKON_HOME=/srv/www && source /usr/local/bin/virtualenvwrapper.sh && mkvirtualenv james --no-site-packages --distribute"
Aborting.

figured out that the position of --no-site-packages and --distribute has to be in front of the virtualenv name to return 0 such as
mkvirtualenv --no-site-packages --distribute <name>

Related

what is this error in NVM jenkins build : ERROR: Failed to fork bash?

I installed nvm-wrapper plugin and set it in my build steps.when I trying to build my angular project the build phase encounter failure and below is console output .what is the problem?
NVM is already installed
[admin] $ bash -c "export > env.txt"
[admin] $ bash -c "NVM_DIR=$HOME/.nvm && source $NVM_DIR/nvm.sh --no-use &&
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 14.20.0 && nvm use 14.20.0 &&
export > env.txt"
Version '14.20.0' not found - try `nvm ls-remote` to browse available versions.
ERROR: Failed to fork bash
Finished: FAILURE

Running default RN native project in iOS gives error

Any idea what is going wrong? I have updated all the relevant components to their latest version.
I am creating a default react-native project and trying to run the iOS simulator
npx react-native init {project_name}
cd {project_name}
npx react-native run-ios
I receive the following error:
/bin/sh -c {user}/Library/Developer/Xcode/DerivedData/{project_name}-epegcqhmisnuaeenegumkazvqqys/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB404279F232A.sh
N/A: version "default -> N/A" is not yet installed.
You need to run "nvm install default" to install it before using it.
Command PhaseScriptExecution failed with a nonzero exit code
The script (self-generated) in question is below:
#!/bin/sh
set -o pipefail
set -e
RN_DIR=$(cd "${PODS_TARGET_SRCROOT}/../.." && pwd)
GENERATED_SRCS_DIR="${DERIVED_FILE_DIR}/generated/source/codegen"
GENERATED_SCHEMA_FILE="$GENERATED_SRCS_DIR/schema.json"
TEMP_OUTPUT_DIR="$GENERATED_SRCS_DIR/out"
LIBRARY_NAME="FBReactNativeSpec"
OUTPUT_DIR="${PODS_TARGET_SRCROOT}/../../React/FBReactNativeSpec/FBReactNativeSpec"
CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen"
CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen"
CODEGEN_CLI_PATH=""
# Determine path to react-native-codegen
if [ -d "$CODEGEN_REPO_PATH" ]; then
CODEGEN_CLI_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
elif [ -d "$CODEGEN_NPM_PATH" ]; then
CODEGEN_CLI_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd)
else
echo "error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
exit 1
fi
find_node () {
source "$RN_DIR/scripts/find-node.sh"
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
if [ -z "$NODE_BINARY" ]; then
echo "error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
exit 1
fi
}
setup_dirs () {
set +e
rm -rf "$GENERATED_SRCS_DIR"
set -e
mkdir -p "$GENERATED_SRCS_DIR" "$TEMP_OUTPUT_DIR"
# Clear output files
> "${SCRIPT_OUTPUT_FILE_0}"
}
describe () {
printf "\n\n>>>>> %s\n\n\n" "$1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
}
buildCodegenCLI () {
if [ ! -d "$CODEGEN_CLI_PATH/lib" ]; then
describe "Building react-native-codegen package"
bash "$CODEGEN_CLI_PATH/scripts/oss/build.sh"
fi
}
generateCodegenSchemaFromJavaScript () {
describe "Generating codegen schema from JavaScript"
SRCS_PATTERN="Native*.js"
SRCS_DIR="../../Libraries"
if [ $SRCS_PATTERN ]; then
JS_SRCS=$(find "${PODS_TARGET_SRCROOT}"/$SRCS_DIR -type f -name "$SRCS_PATTERN" -print0 | xargs -0)
echo "["../../Libraries/ActionSheetIOS/NativeActionSheetManager.js", "../../Libraries/Alert/NativeAlertManager.js", "../../Libraries/Animated/NativeAnimatedHelper.js", "../../Libraries/Animated/NativeAnimatedModule.js", "../../Libraries/Animated/NativeAnimatedTurboModule.js", "../../Libraries/AppState/NativeAppState.js", "../../Libraries/BatchedBridge/NativeModules.js", "../../Libraries/Blob/NativeBlobModule.js", "../../Libraries/Blob/NativeFileReaderModule.js", "../../Libraries/BugReporting/NativeBugReporting.js", "../../Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js", "../../Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js", "../../Libraries/Components/Clipboard/NativeClipboard.js", "../../Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js", "../../Libraries/Components/Keyboard/NativeKeyboardObserver.js", "../../Libraries/Components/Sound/NativeSoundManager.js", "../../Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js", "../../Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js", "../../Libraries/Components/ToastAndroid/NativeToastAndroid.js", "../../Libraries/Core/NativeExceptionsManager.js", "../../Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js", "../../Libraries/Core/Timers/NativeTiming.js", "../../Libraries/EventEmitter/NativeEventEmitter.js", "../../Libraries/EventEmitter/__mocks__/NativeEventEmitter.js", "../../Libraries/HeapCapture/NativeJSCHeapCapture.js", "../../Libraries/Image/NativeImageEditor.js", "../../Libraries/Image/NativeImageLoaderAndroid.js", "../../Libraries/Image/NativeImageLoaderIOS.js", "../../Libraries/Image/NativeImagePickerIOS.js", "../../Libraries/Image/NativeImageStoreAndroid.js", "../../Libraries/Image/NativeImageStoreIOS.js", "../../Libraries/Interaction/NativeFrameRateLogger.js", "../../Libraries/Linking/NativeIntentAndroid.js", "../../Libraries/Linking/NativeLinkingManager.js", "../../Libraries/Modal/NativeModalManager.js", "../../Libraries/NativeComponent/NativeComponentRegistry.js", "../../Libraries/NativeModules/specs/NativeAnimationsDebugModule.js", "../../Libraries/NativeModules/specs/NativeDevMenu.js", "../../Libraries/NativeModules/specs/NativeDevSettings.js", "../../Libraries/NativeModules/specs/NativeDeviceEventManager.js", "../../Libraries/NativeModules/specs/NativeDialogManagerAndroid.js", "../../Libraries/NativeModules/specs/NativeLogBox.js", "../../Libraries/NativeModules/specs/NativeRedBox.js", "../../Libraries/NativeModules/specs/NativeSourceCode.js", "../../Libraries/Network/NativeNetworkingAndroid.js", "../../Libraries/Network/NativeNetworkingIOS.js", "../../Libraries/Performance/NativeJSCSamplingProfiler.js", "../../Libraries/PermissionsAndroid/NativePermissionsAndroid.js", "../../Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js", "../../Libraries/ReactNative/NativeHeadlessJsTaskSupport.js", "../../Libraries/ReactNative/NativeI18nManager.js", "../../Libraries/ReactNative/NativeUIManager.js", "../../Libraries/Settings/NativeSettingsManager.js", "../../Libraries/Share/NativeShareModule.js", "../../Libraries/Storage/NativeAsyncLocalStorage.js", "../../Libraries/Storage/NativeAsyncSQLiteDBStorage.js", "../../Libraries/TurboModule/samples/NativeSampleTurboModule.js", "../../Libraries/Utilities/NativeAppearance.js", "../../Libraries/Utilities/NativeDevLoadingView.js", "../../Libraries/Utilities/NativeDevSplitBundleLoader.js", "../../Libraries/Utilities/NativeDeviceInfo.js", "../../Libraries/Utilities/NativeJSDevSupport.js", "../../Libraries/Utilities/NativePlatformConstantsAndroid.js", "../../Libraries/Utilities/NativePlatformConstantsIOS.js", "../../Libraries/Vibration/NativeVibration.js", "../../Libraries/WebSocket/NativeWebSocketModule.js"]" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
else
JS_SRCS="${PODS_TARGET_SRCROOT}/$SRCS_DIR"
echo "../../Libraries" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
fi
"$NODE_BINARY" "$CODEGEN_CLI_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$GENERATED_SCHEMA_FILE" $JS_SRCS
}
generateCodegenArtifactsFromSchema () {
describe "Generating codegen artifacts from schema"
pushd "$RN_DIR" >/dev/null || exit 1
"$NODE_BINARY" "scripts/generate-specs-cli.js" ios "$GENERATED_SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$LIBRARY_NAME"
popd >/dev/null || exit 1
}
moveOutputs () {
mkdir -p "$OUTPUT_DIR"
# Copy all output to output_dir
cp -R "$TEMP_OUTPUT_DIR/" "$OUTPUT_DIR" || exit 1
echo "$LIBRARY_NAME output has been written to $OUTPUT_DIR:" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
ls -1 "$OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
}
main () {
setup_dirs
find_node
buildCodegenCLI
generateCodegenSchemaFromJavaScript
generateCodegenArtifactsFromSchema
moveOutputs
}
main "$#"
echo 'Done.' >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
Trying to run from Xcode yields in the same error.
Needless to say, I tried running
nvm install default
and received the following error:
Version 'default' not found - try `nvm ls-remote` to browse available versions.
I don't answer on Stackoverflow often but I had the same issue and used this post to solve it.
It basically revolves around the command
nvm alias default system
or swapping system to whatever version of NodeJS you would like.
I had the same issue when building the IOS app.
Open a terminal and type:
git clone https://github.com/nvm-sh/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
nvm alias default system
Rather than modifying the system node, applying the commit that removes the find-node.sh script with patch-package fixed this issue for a dev on our team who was stuck with this issue.
The contents of our patch is simply
diff --git a/node_modules/react-native/scripts/find-node.sh b/node_modules/react-native/scripts/find-node.sh
deleted file mode 100755
index 5d6d2c4..0000000
--- a/node_modules/react-native/scripts/find-node.sh
+++ /dev/null
## -1,56 +0,0 ##
-#!/bin/bash
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-set -e
-
-# remove global prefix if it's already set
-# the running shell process will choose a node binary and a global package directory breaks version managers
-unset PREFIX
-
-# Support Homebrew on M1
-HOMEBREW_M1_BIN=/opt/homebrew/bin
-if [[ -d $HOMEBREW_M1_BIN && ! $PATH =~ $HOMEBREW_M1_BIN ]]; then
- export PATH="$HOMEBREW_M1_BIN:$PATH"
-fi
-
-# Define NVM_DIR and source the nvm.sh setup script
-[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
-
-# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc
-# See: https://github.com/nvm-sh/nvm/issues/2053
-if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
- # shellcheck source=/dev/null
- . "$HOME/.nvm/nvm.sh" --no-use
- nvm use 2> /dev/null || nvm use default
-elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
- # shellcheck source=/dev/null
- . "$(brew --prefix nvm)/nvm.sh" --no-use
- nvm use 2> /dev/null || nvm use default
-fi
-
-# Set up the nodenv node version manager if present
-if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
- eval "$("$HOME/.nodenv/bin/nodenv" init -)"
-elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
- eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
-fi
-
-# Set up the ndenv of anyenv if preset
-if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
- export PATH=${HOME}/.anyenv/bin:${PATH}
- if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
- eval "$(anyenv init -)"
- fi
-fi
-
-# Set up asdf-vm if present
-if [[ -f "$HOME/.asdf/asdf.sh" ]]; then
- # shellcheck source=/dev/null
- . "$HOME/.asdf/asdf.sh"
-elif [[ -x "$(command -v brew)" && -f "$(brew --prefix asdf)/asdf.sh" ]]; then
- # shellcheck source=/dev/null
- . "$(brew --prefix asdf)/asdf.sh"
-fi
diff --git a/node_modules/react-native/scripts/react-native-xcode.sh b/node_modules/react-native/scripts/react-native-xcode.sh
index 3ef9a71..304a5dc 100755
--- a/node_modules/react-native/scripts/react-native-xcode.sh
+++ b/node_modules/react-native/scripts/react-native-xcode.sh
## -79,9 +79,7 ## if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
exit 2
fi
-# Find path to Node
-# shellcheck source=/dev/null
-source "$REACT_NATIVE_DIR/scripts/find-node.sh"
+NODE_BINARY="$(command -v node)"
# check and assign NODE_BINARY env
# shellcheck source=/dev/null
diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb
index 1b8a078..d65c9ca 100644
--- a/node_modules/react-native/scripts/react_native_pods.rb
+++ b/node_modules/react-native/scripts/react_native_pods.rb
## -289,8 +289,6 ## else
fi
find_node () {
- source "$RN_DIR/scripts/find-node.sh"
-
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
if [ -z "$NODE_BINARY" ]; then
echo "error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1

Python doit module: How to choose which shell to run task actions?

I am using python doit module as a GNU make replacement.
Seems that doit is running actions on /bin/sh:
pedro#Gen83-ubuntu:~$ echo $SHELL
/bin/bash
pedro#Gen83-ubuntu:~$ doit merge_phased
. phase_dataset:15
/bin/sh: 1: [[: not found
TaskError - taskid:phase_dataset:15
Command error: '[[ ! -d phasing ]] && mkdir phasing' returned 127
########################################
phase_dataset:15 <stdout>:
I would like to use /bin/bash. I could not find how to accomplish that in the documentation.
if its a sh file then you can add this at the top to run with bash
#!/bin/bash
or
#!/bin/ksh
to run with ksh

Unable to run npm command in ansible awx_task container

I have been using ansible core for some time now and expanding my team so the need for ansible awx has become a little more pressing. I have been working at it for a week now and I think it's time to shout for help.
We had a process of replacing the baseurl of angularjs apps with some variable using ansible and set some settings before we compile it (currently thinking of a different way of doing this using build server like TeamCity but not right now we we are trying to be up with ansible awx).
ansible core checks out the code from the git branch version , replaces the variables and zip it to s3 etc.
Knowing that, the ansible awx host was configured with the nvm then node was installed and the .nvm mapped to /home/awx/.nvm
I have also mapped a bashrc to /home/awx/.bashrc. When I log into the awx_task container docker exec -it awx_task /bin/bash I see the below:
[root#awx ~]# npm --version
5.5.1
[root#awx ~]# echo $PATH /home/awx/.nvm/versions/node/v8.9.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[root#awx ~]# env
NVM_DIR=/home/awx/.nvm
LANG=en_US.UTF-8
HOSTNAME=awx
NVM_CD_FLAGS=
DO_ANSIBLE_HOME=/opt/do_ansible_awx_home
PWD=/home/awx
HOME=/home/awx
affinity:container==eb57afe832eaa32472812d0cd8b614be6df213d8e866f1d7b04dfe109a887e44
TERM=xterm
NVM_BIN=/home/awx/.nvm/versions/node/v8.9.3/bin
SHLVL=1
LANGUAGE=en_US:en
PATH=/home/awx/.nvm/versions/node/v8.9.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LESSOPEN=||/usr/bin/lesspipe.sh %s
_=/usr/bin/env
[root#awx ~]# cat /home/awx/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
All the volume mappings, etc were done with the installer role templates and tasks so the output above is the same after multiple docker restart and reinstall running the ansible awx installer playbook. But during the execution of the playbook that makes use of the npm, it seems it has a different env PATH: /var/lib/awx/venv/ansible/bin:/var/lib/awx/venv/awx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
At this point, I am not sure whether I failed to configure the path properly or other containers like awx_web should also be configured etc.
I have also noticed the env NVM_BIN and modified the npm playbook to include the path to the npm executable:
- name: Running install to build npm modules
npm:
path: "{{ bps_git_checkout_folder }}"
executable: "{{ lookup('env','NVM_BIN') }}/npm"
and it doens't even show during execution thus pointing at different path and env variables being loaded.
I will be grateful if you could shed some lights on whatever I am doing wrongly.
Thanks in advance
EDITS : After implementing #sergei suggestion I have used the extra vars npm_bin: /home/awx/.nvm/versions/node/v8.9.3/bin
I have changed the task to look like:
- name: Running install to build npm modules
npm:
path: "{{ bps_git_checkout_folder }}"
executable: "{{ npm_bin }}/npm"
But it produced this result:
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209 `" && echo
ansible-tmp-1579790680.4419668-165048670233209="` echo /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209 `" ) &&
sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/packaging/language/npm.py
<127.0.0.1> PUT /var/lib/awx/.ansible/tmp/ansible-local-10173xtu81x_o/tmpd40htayd TO /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/AnsiballZ_npm.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/ /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/AnsiballZ_npm.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/AnsiballZ_npm.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/AnsiballZ_npm.py", line 114, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/AnsiballZ_npm.py", line 106, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1579790680.4419668-165048670233209/AnsiballZ_npm.py", line 49, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/usr/lib64/python3.6/imp.py", line 235, in load_module
return load_source(name, filename, file)
File "/usr/lib64/python3.6/imp.py", line 170, in load_source
module = _exec(spec, sys.modules[name])
File "<frozen importlib._bootstrap>", line 618, in _exec
File "<frozen importlib._bootstrap…
PLAY RECAP
*********************************************************************
localhost : ok=5 changed=4 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
I have also tried to use shell module directly with the following:
- name: Running npm install
shell: "{{ npm_bin }}/npm install"
args:
chdir: "{{ bps_git_checkout_folder }}"
That has produced this instead:
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218 `" && echo
ansible-tmp-1579791187.453365-253173616238218="` echo /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218 `" ) &&
sleep 0'
Using module file /usr/lib/python3.6/site- packages/ansible/modules/commands/command.py
<127.0.0.1> PUT /var/lib/awx/.ansible/tmp/ansible-local-10395h1ga8fw3/tmpepeig729 TO /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218/AnsiballZ_command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218/ /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1579791187.453365-253173616238218/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
"changed": true,
"cmd": "/home/awx/.nvm/versions/node/v8.9.3/bin/npm install",
"delta": "0:00:00.005528",
"end": "2020-01-23 14:53:07.928843",
"invocation": {
"module_args": {
"_raw_params": "/home/awx/.nvm/versions/node/v8.9.3/bin/npm install",
"_uses_shell": true,
"argv": null,
"chdir": "/opt/do_ansible_awx_home/gh/deployments/sandbox/bps",
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"msg": "non-zero return code",
"rc": 127,
…
PLAY RECAP
*********************************************************************
localhost : ok=5 changed=4 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Not really seeing what's wrong here . Grateful if anybody can share some lights on this.
Where is your packages sitting? In the host or inside the container? All execution is in the task container.
If you're npm files are sitting on the 'host' and not in the container then you have to refer to the host that the containers are sitting on to to refer to the path.

How to install nvm in a Dockerfile?

I'm trying to install nvm within a Dockerfile. It seems like it installs OK, but the nvm command is not working.
Dockerfile:
# Install nvm
RUN git clone http://github.com/creationix/nvm.git /root/.nvm;
RUN chmod -R 777 /root/.nvm/;
RUN sh /root/.nvm/install.sh;
RUN export NVM_DIR="$HOME/.nvm";
RUN echo "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" >> $HOME/.bashrc;
RUN nvm ls-remote;
Build output:
Step 23/39 : RUN git clone http://github.com/creationix/nvm.git /root/.nvm;
---> Running in ca485a68b9aa
Cloning into '/root/.nvm'...
---> a6f61d486443
Removing intermediate container ca485a68b9aa
Step 24/39 : RUN chmod -R 777 /root/.nvm/
---> Running in 6d4432926745
---> 30e7efc5bd41
Removing intermediate container 6d4432926745
Step 25/39 : RUN sh /root/.nvm/install.sh;
---> Running in 79b517430285
=> Downloading nvm from git to '$HOME/.nvm'
=> Cloning into '$HOME/.nvm'...
* (HEAD detached at v0.33.0)
master
=> Compressing and cleaning up git repository
=> Appending nvm source string to /root/.profile
=> bash_completion source string already in /root/.profile
npm info it worked if it ends with ok
npm info using npm#3.10.10
npm info using node#v6.9.5
npm info ok
=> Installing Node.js version 6.9.5
Downloading and installing node v6.9.5...
Downloading https://nodejs.org/dist/v6.9.5/node-v6.9.5-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v6.9.5 (npm v3.10.10)
Creating default alias: default -> 6.9.5 (-> v6.9.5 *)
/root/.nvm/install.sh: 136: [: v6.9.5: unexpected operator
Failed to install Node.js 6.9.5
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
---> 9f6f3e74cd19
Removing intermediate container 79b517430285
Step 26/39 : RUN export NVM_DIR="$HOME/.nvm";
---> Running in 1d768138e3d5
---> 8039dfb4311c
Removing intermediate container 1d768138e3d5
Step 27/39 : RUN echo "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" >> $HOME/.bashrc;
---> Running in d91126b7de62
---> 52313e09866e
Removing intermediate container d91126b7de62
Step 28/39 : RUN nvm ls-remote;
---> Running in f13c1ed42b3a
/bin/sh: 1: nvm: not found
The command '/bin/sh -c nvm ls-remote;' returned a non-zero code: 127
The error:
Step 28/39 : RUN nvm ls-remote;
---> Running in f13c1ed42b3a
/bin/sh: 1: nvm: not found
The command '/bin/sh -c nvm ls-remote;' returned a non-zero code: 127
The end of my /root/.bashrc file looks like:
[[ -s /root/.nvm/nvm.sh ]] && . /root/.nvm/nvm.sh
Everything else in the Dockerfile works. Adding the nvm stuff is what broke it. Here is the full file.
I made the following changes to your Dockerfile to make it work:
First, replace...
RUN sh /root/.nvm/install.sh;
...with:
RUN bash /root/.nvm/install.sh;
Why? On Redhat-based systems, /bin/sh is a symlink to /bin/bash. But on Ubuntu, /bin/sh is a symlink to /bin/dash. And this is what happens with dash:
root#52d54205a137:/# bash -c '[ 1 == 1 ] && echo yes!'
yes!
root#52d54205a137:/# dash -c '[ 1 == 1 ] && echo yes!'
dash: 1: [: 1: unexpected operator
Second, replace...
RUN nvm ls-remote;
...with:
RUN bash -i -c 'nvm ls-remote';
Why? Because, the default .bashrc for a user in Ubuntu (almost at the top) contains:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
And the source-ing of nvm's scripts takes place at the bottom. So we need to make sure that bash is invoked interactively by passing the argument -i.
Third, you could skip the following lines in your Dockerfile:
RUN export NVM_DIR="$HOME/.nvm";
RUN echo "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" >> $HOME/.bashrc;
Why? Because bash /root/.nvm/install.sh; will automatically do it for you:
[fedora#myhost ~]$ sudo docker run --rm -it 2a283d6e2173 tail -2 /root/.bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Instalation of nvm on ubuntu in dockerfile
In the case of Ubuntu 20.04 you can use only these commands and everything will be alright
FROM ubuntu:20.04
RUN apt update -y && apt upgrade -y && apt install wget bash -y
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
RUN bash -i -c 'nvm ls-remote'
hopefully it will work

Resources