Normalize Windows PWD before nvm install#24
Merged
Conversation
nvm v0.39.4 can loop forever while resolving `.nvmrc` from a Windows-shaped `PWD` under Git Bash/MSYS/Cygwin. Convert that working directory to its POSIX form before invoking nvm so `.nvmrc` lookup and activation run from a path nvm can trim safely. The CI coverage keeps the exact Beeper Node version and a second modern version on Windows, plus a Windows `.nvmrc` fallback check. --- Generated with the help of OpenAI Codex, https://openai.com/codex
2720f83 to
5ea78ee
Compare
The verifier should avoid command-phase `nvm use`, but it does not need to assert the shell executable path. Using `nvm current` keeps the legacy version matrix working while the hook-level smoke tests and Windows jobs cover the path-normalization fix. --- Generated with the help of OpenAI Codex, https://openai.com/codex
On Windows, sourcing nvm with `--no-use` leaves `nvm current` reporting `system` even when the hook activated the requested Node executable. Check `node --version` there, while keeping the legacy `nvm current` check for the non-Windows matrix. --- Generated with the help of OpenAI Codex, https://openai.com/codex
Generate the `.nvmrc` fallback fixture from a Buildkite repository hook instead of committing it as project configuration. Also document the Windows verifier branch and why the helper library leaves strict mode to its callers. --- Generated with the help of OpenAI Codex, https://openai.com/codex
mokagio
commented
Jun 30, 2026
mokagio
commented
Jun 30, 2026
Co-authored-by: Gio Lodi <giovanni.lodi42@gmail.com>
The fallback checks already set the version used to generate `.nvmrc`. Pass that same value to the verifier instead of repeating the literal in the command. --- Generated with the help of OpenAI Codex, https://openai.com/codex
Buildkite exposes the fixture env var to repository hooks, but it is not present when the command runs. Read the generated `.nvmrc` file in the verifier command instead of repeating the version literal. --- Generated with the help of OpenAI Codex, https://openai.com/codex
mokagio
commented
Jun 30, 2026
Windows agents can reach nvm code while `PWD` still has a drive-letter path. Normalize before sourcing `nvm.sh`, so every nvm code path sees a POSIX-shaped working directory. --- Generated with the help of OpenAI Codex, https://openai.com/codex
mokagio
commented
Jun 30, 2026
Co-authored-by: Gio Lodi <giovanni.lodi42@gmail.com>
1 task
Convert common Windows PWD shapes in Bash before nvm loads. This removes another external command from the path where build 111 appears to stall before printing the normalization message. --- Generated with the help of Codex, https://openai.com/codex Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Comment on lines
+57
to
+66
| local normalized_pwd | ||
| if ! normalized_pwd="$(nvm_plugin_windows_pwd_to_posix "$PWD")"; then | ||
| echo "Cannot normalize Windows PWD for nvm from ${PWD}" | ||
| return 0 | ||
| fi | ||
|
|
||
| if [[ -z "$normalized_pwd" || "$normalized_pwd" == "$PWD" ]]; then | ||
| echo "Cannot normalize Windows PWD for nvm from ${PWD}" | ||
| return 0 | ||
| fi |
Comment on lines
+1
to
6
| test: | ||
| bash tests/nvm-plugin-helpers-test.sh | ||
| bash tests/pre-command-smoke-test.sh | ||
|
|
||
| validate: | ||
| docker run -it --rm -v "$(shell pwd):/plugin:ro" buildkite/plugin-linter --id automattic/nvm |
iangmaia
reviewed
Jun 30, 2026
| return 0 | ||
| fi | ||
|
|
||
| if [[ ! -d "$normalized_pwd" ]]; then |
Contributor
There was a problem hiding this comment.
If we detect a Windows PWD that needs normalization but the normalized path does not exist, the helper logs and returns success, then we continue into source "$NVM_DIR/nvm.sh" --no-use. Since we're trying to avoid nvm getting stuck on that bad PWD, should this case fail fast instead? 🤔
iangmaia
approved these changes
Jun 30, 2026
iangmaia
left a comment
Contributor
There was a problem hiding this comment.
Assuming further testing on currently blocking jobs and that you're going to consider the review comments (not sure if they're blocker though), approving to unblock
The explicit-version Windows jobs hang and get killed (`0xC000013A`): with no `.nvmrc` in the working directory, nvm v0.39.4's ancestor walk loops forever under the Windows agent's bash. Setting `NVM_BUILDKITE_PLUGIN_TEST_NVMRC_VERSION` makes the repo `pre-command` hook write one before the plugin runs, short-circuiting the walk. The plugin still installs via the `version:` property; the `.nvmrc` is only there to satisfy nvm's directory walk, so this is a CI-harness fix with no change to the plugin. Proven green by build 116 (PR #29 experiment). --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
🤔 I must have touched the wrong control on GitHub's mobile when looking at this PR because it was not my intention to merge it... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since switching to Elastic CI Stack 6.67.0, our Windows machines hung when installing Node using the plugin.
I got GPT 5.5 to run a bunch of experiments and it discovered the issue was due to the
/vs\paths and hownvmhandles them in thePWDlookup.Also verified this doesn't break other repos that were not affected, e.g. Studio via Automattic/studio#3999
The fix, verified in those pipelines that were hanging and with new tests in CI to avoid regression, was to normalize Windows'
PWDto the POSIX form.AI-generated details
Rationale
nvm installcan hang on Windows when Buildkite starts the hook with a Windows-shapedPWD, such asC:\....In nvm v0.39.4,
.nvmrclookup walksPWDby trimming/; a Windows drive path can collapse toC:and loop forever.This normalizes Windows
PWDto the POSIX form withcygpath -ubefore invoking nvm, so.nvmrclookup and activation run from a path nvm can trim safely.CI coverage
v20.19.5andv24.15.0.nvmrcfallback:20.19.5make testHow to test
make testshellcheck hooks/pre-command hooks/lib/nvm-buildkite-plugin.bash tests/nvm-plugin-helpers-test.sh tests/pre-command-smoke-test.sh .buildkite/verify_node.shruby -e 'require "yaml"; YAML.load_file(".buildkite/pipeline.yml")'buildkite-agent pipeline upload --dry-run --format yaml --agent-access-token dummy .buildkite/pipeline.ymlBuildkite #102 passed.
Posted by Codex (GPT-5) on behalf of @mokagio with approval.