From 84079dbff3c6094e3742aa0abc01af90e15f8381 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 3 Jun 2026 20:12:26 -0700 Subject: [PATCH] [Tests] `install_nvm_from_git`: stop git background gc/maintenance racing with cleanup The test's `rm -rf "$NVM_DIR"` intermittently failed with `rm: cannot remove...: Directory not empty` and aborted under `set -e`. Cause: after the clone/fetch, git can spawn a detached background gc/maintenance process that keeps writing into the clone dir while `rm -rf` runs (a concurrent writer makes the final rmdir fail). It is not egress- or version-related (it reproduces with all endpoints allowed), and it is environment-timing dependent (recently became consistent on the GitHub runners). Disable git's background work for the test (gc.autoDetach / maintenance.auto) so all git operations finish synchronously, and retry the rm once as a safety net. --- test/install_script/install_nvm_from_git | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/install_script/install_nvm_from_git b/test/install_script/install_nvm_from_git index 4a89b592..8d1ea030 100755 --- a/test/install_script/install_nvm_from_git +++ b/test/install_script/install_nvm_from_git @@ -17,6 +17,9 @@ NVM_ENV=testing \. ../../install.sh set -ex +git config --global gc.autoDetach false +git config --global maintenance.auto false + # nvm_do_install is available type install_nvm_from_git > /dev/null 2>&1 || die 'install_nvm_from_git is not available' @@ -94,14 +97,14 @@ test_install() { test_step "Clones repo $message" install_nvm_from_git test_install_data "$(get_head_ref)" "$(get_head_changeset)" "$message" "$ref" "$changeset" "$avoid_ref" - rm -rf "$NVM_DIR" + rm -rf "$NVM_DIR" || { sleep 1; rm -rf "$NVM_DIR"; } # Ensure it initializes the repository for an empty existing repository mkdir -p "$NVM_DIR" || die 'Unable to create directory' test_step "Initialize repo $message" install_nvm_from_git test_install_data "$(get_head_ref)" "$(get_head_changeset)" "$message" "$ref" "$changeset" "$avoid_ref" - rm -rf "$NVM_DIR" + rm -rf "$NVM_DIR" || { sleep 1; rm -rf "$NVM_DIR"; } # Ensure it updates the repository for an existing git repository git clone "$(nvm_source "git")" -b "v0.36.0" --depth=2 "$NVM_DIR" || die 'Unable to clone repository' @@ -109,7 +112,7 @@ test_install() { test_step "Updates repo $message" install_nvm_from_git test_install_data "$(get_head_ref)" "$(get_head_changeset)" "$message" "$ref" "$changeset" "$avoid_ref" - rm -rf "$NVM_DIR" + rm -rf "$NVM_DIR" || { sleep 1; rm -rf "$NVM_DIR"; } } # Handle latest version