From c9e7bb2da1bdaffe15f9a1d1bededb533a172138 Mon Sep 17 00:00:00 2001 From: Nix Date: Sat, 23 Oct 2021 22:23:55 +0900 Subject: [PATCH 1/8] [Fix] install script: Add `--no-pager` option to git branch --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index af8fb6e..c5bc50f 100755 --- a/install.sh +++ b/install.sh @@ -160,11 +160,11 @@ install_nvm_from_git() { exit 2 } if [ -n "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then - if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then - command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1 + if command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then + command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1 else nvm_echo >&2 "Your version of git is out of date. Please update it!" - command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1 + command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1 fi fi From 2f40eeef2e201779b942c1c8bd241d058f5d2273 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 19 Nov 2021 08:53:43 -0800 Subject: [PATCH 2/8] [shellcheck] apply v0.8.0 updates --- install.sh | 2 +- nvm.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index c5bc50f..d6433ce 100755 --- a/install.sh +++ b/install.sh @@ -300,7 +300,7 @@ nvm_detect_profile() { nvm_check_global_modules() { local NPM_COMMAND NPM_COMMAND="$(command -v npm 2>/dev/null)" || return 0 - [ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%$NVM_DIR/*}" ] && return 0 + [ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%"$NVM_DIR"/*}" ] && return 0 local NPM_VERSION NPM_VERSION="$(npm --version)" diff --git a/nvm.sh b/nvm.sh index 72992c1..f65e991 100644 --- a/nvm.sh +++ b/nvm.sh @@ -634,7 +634,7 @@ nvm_remote_versions() { NVM_LS_REMOTE_EXIT_CODE=$? # split output into two NVM_LS_REMOTE_PRE_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT%%v4\.0\.0*}" - NVM_LS_REMOTE_POST_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT#$NVM_LS_REMOTE_PRE_MERGED_OUTPUT}" + NVM_LS_REMOTE_POST_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT#"$NVM_LS_REMOTE_PRE_MERGED_OUTPUT"}" fi local NVM_LS_REMOTE_IOJS_EXIT_CODE @@ -940,7 +940,7 @@ nvm_print_alias_path() { return 2 fi local ALIAS - ALIAS="${ALIAS_PATH##${NVM_ALIAS_DIR}\/}" + ALIAS="${ALIAS_PATH##"${NVM_ALIAS_DIR}"\/}" local DEST DEST="$(nvm_alias "${ALIAS}" 2>/dev/null)" ||: if [ -n "${DEST}" ]; then @@ -1186,7 +1186,7 @@ nvm_strip_iojs_prefix() { if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then nvm_echo else - nvm_echo "${1#${NVM_IOJS_PREFIX}-}" + nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" fi } @@ -2614,7 +2614,7 @@ nvm_node_version_has_solaris_binary() { # Succeeds if $VERSION represents a version (node, io.js or merged) that has a # Solaris binary, fails otherwise. nvm_has_solaris_binary() { - local VERSION=$1 + local VERSION="${1-}" if nvm_is_merged_node_version "${VERSION}"; then return 0 # All merged node versions have a Solaris binary elif nvm_is_iojs_version "${VERSION}"; then From ccd98f7fcbae2a41ae4a00ab7ba50727732dd4b2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 19 Nov 2021 08:59:37 -0800 Subject: [PATCH 3/8] [Dev Deps] update `doctoc` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0630c6..dc3efd5 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "homepage": "https://github.com/nvm-sh/nvm", "devDependencies": { "dockerfile_lint": "^0.3.4", - "doctoc": "^2.0.1", + "doctoc": "^2.1.0", "eclint": "^2.8.1", "markdown-link-check": "^3.8.7", "replace": "^1.2.1", From e9b26938b953278b0e6c0d1812e20267358f8f5e Mon Sep 17 00:00:00 2001 From: Ian Grayson Date: Mon, 15 Nov 2021 04:23:42 -0800 Subject: [PATCH 4/8] [readme] Describe another failure case for installing node versions from source on mac arm64 machines. It seems to be related to https://github.com/nodejs/node/issues/39313 (which describes a similar issue). --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8891021..658b704 100644 --- a/README.md +++ b/README.md @@ -913,6 +913,7 @@ Some issues you may encounter: $ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package ``` - when using `nvm` to install some versions, the compilation fails +- after `nvm` successfully compiles some versions, `yarn` or `npm` may later fail to install packages with an `incorrect data check` error. One solution to this issue is to change the architecture of your shell from arm64 to x86. From 30486b9bd9b88c875b78f0ea9fd71801be6af46b Mon Sep 17 00:00:00 2001 From: Robert Elliot Date: Mon, 22 Nov 2021 14:34:43 +0000 Subject: [PATCH 5/8] [readme] Balance the if statement in bash example Nesting the `elif` at the same level as the `if` and `fi` makes it clear which code applies to which branch (no .nvmrc file / found .nvmrc file). I wasted a while looking at it trying to work out how it did anything if there was a .nvmrc file, because obviously the `if` didn't match and I couldn't see the `elif` branch. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 658b704..4f2b588 100644 --- a/README.md +++ b/README.md @@ -572,7 +572,7 @@ cdnvm() { nvm use default; fi - elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then + elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then declare nvm_version nvm_version=$(<"$nvm_path"/.nvmrc) From 89379176ac5f6604ca0bafa7f9d20951da620fdd Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 25 Nov 2021 14:26:35 -0800 Subject: [PATCH 6/8] [Fix] `install`: properly check for curl/wget --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index d6433ce..a4a12ba 100755 --- a/install.sh +++ b/install.sh @@ -360,7 +360,7 @@ nvm_do_install() { # Autodetect install method if nvm_has git; then install_nvm_from_git - elif nvm_has nvm_download; then + elif nvm_has curl || nvm_has wget; then install_nvm_as_script else nvm_echo >&2 'You need git, curl, or wget to install nvm' @@ -373,7 +373,7 @@ nvm_do_install() { fi install_nvm_from_git elif [ "${METHOD}" = 'script' ]; then - if ! nvm_has nvm_download; then + if ! nvm_has curl || nvm_has wget; then nvm_echo >&2 "You need curl or wget to install nvm" exit 1 fi From 275001b06642f9ee35776b06a37c16b67ccf2328 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 25 Nov 2021 19:35:39 -0800 Subject: [PATCH 7/8] [Tests] fix windows WSL tests --- .github/workflows/windows-npm.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-npm.yml b/.github/workflows/windows-npm.yml index 90c5002..6281a42 100644 --- a/.github/workflows/windows-npm.yml +++ b/.github/workflows/windows-npm.yml @@ -87,6 +87,9 @@ jobs: wsl_matrix: name: 'WSL nvm install' + defaults: + run: + shell: wsl-bash {0} runs-on: windows-latest env: WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p @@ -99,19 +102,24 @@ jobs: - Ubuntu-18.04 npm-node-version: - '--lts' + - '14' + - '12' - '11' + - '10' + method: + - '' + # - 'script' # TODO: uncomment this. steps: - uses: Vampire/setup-wsl@v1 with: distribution: ${{ matrix.wsl-distrib }} - additional-packages: bash git curl ca-certificates + additional-packages: bash git curl ca-certificates wget - name: Retrieve nvm on WSL - shell: wsl-bash {0} run: | - if [ "${{ matrix.wsl-distrib }}" = "Ubuntu-18.04" ] && [ "${{ matrix.npm-node-version }}" = "--lts" ]; then + if [ -z "${{ matrix.method }}" ]; then curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash else - curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash + curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash fi . "$HOME/.nvm/nvm.sh" nvm install ${{ matrix.npm-node-version }} From 4856407d2691d2135420f25d00acdb6d9b85ae3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Foray?= Date: Tue, 30 Nov 2021 16:07:22 +0100 Subject: [PATCH 8/8] [Fix] `install`: fix method=script install condition Fixes #2665; see 8937917 --- .github/workflows/windows-npm.yml | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-npm.yml b/.github/workflows/windows-npm.yml index 6281a42..29fef33 100644 --- a/.github/workflows/windows-npm.yml +++ b/.github/workflows/windows-npm.yml @@ -108,7 +108,7 @@ jobs: - '10' method: - '' - # - 'script' # TODO: uncomment this. + - 'script' steps: - uses: Vampire/setup-wsl@v1 with: diff --git a/install.sh b/install.sh index a4a12ba..eb37d04 100755 --- a/install.sh +++ b/install.sh @@ -373,7 +373,7 @@ nvm_do_install() { fi install_nvm_from_git elif [ "${METHOD}" = 'script' ]; then - if ! nvm_has curl || nvm_has wget; then + if ! nvm_has curl && ! nvm_has wget; then nvm_echo >&2 "You need curl or wget to install nvm" exit 1 fi