node-orb
node-orb copied to clipboard
Occasional flake when setting up node
Orb version:
5.0.0
What happened:
We occasionally see flaky builds where node or NPM fails to install. For example, here's the output from one recent failure:
failure output
#!/bin/bash -eo pipefail
# Only install nvm if it's not already installed
if command -v nvm &> /dev/null; then
echo "nvm is already installed. Skipping nvm install.";
else
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash;
echo 'export NVM_DIR="$HOME/.nvm"' >> "$BASH_ENV";
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use' >> "$BASH_ENV";
# shellcheck source=/dev/null
source "$BASH_ENV";
fi
# See: https://github.com/nvm-sh/nvm#usage
if [ "$NODE_PARAM_VERSION" = "latest" ]; then
# When no version is specified we default to the latest version of Node
NODE_ORB_INSTALL_VERSION=$(nvm ls-remote | tail -n1 | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+')
nvm install "$NODE_ORB_INSTALL_VERSION" # aka nvm install node. We're being explicit here.
nvm alias default "$NODE_ORB_INSTALL_VERSION"
elif [ -n "$NODE_PARAM_VERSION" ]; then
nvm install "$NODE_PARAM_VERSION"
nvm alias default "$NODE_PARAM_VERSION"
elif [ -f ".nvmrc" ]; then
NVMRC_SPECIFIED_VERSION=$(<.nvmrc)
nvm install "$NVMRC_SPECIFIED_VERSION"
nvm alias default "$NVMRC_SPECIFIED_VERSION"
else
nvm install --lts
nvm alias default lts/*
fi
echo 'nvm use default &>/dev/null' >> "$BASH_ENV"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 1016k 0 --:--:-- --:--:-- --:--:-- 1016k
=> Downloading nvm from git to '/home/circleci/.nvm'
=> Cloning into '/home/circleci/.nvm'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Failed to clone nvm repo. Please report this!
Exited with code exit status 2
CircleCI received exit code 2
Expected behavior:
Node should reliably install in the container.