Skip to content

[actions] Fix Cygwin workflow HOME variable to resolve nvm installation path issues#3611

Merged
ljharb merged 1 commit intomasterfrom
copilot/fix-8ef89578-ccbd-4ee7-ac81-d932c26324eb
Jul 3, 2025
Merged

[actions] Fix Cygwin workflow HOME variable to resolve nvm installation path issues#3611
ljharb merged 1 commit intomasterfrom
copilot/fix-8ef89578-ccbd-4ee7-ac81-d932c26324eb

Conversation

Copy link
Contributor

Copilot AI commented Jul 3, 2025

Problem

The Cygwin workflow in .github/workflows/windows-npm.yml was failing because $HOME/.nvm/nvm.sh does not exist after running the install script under Cygwin. This is due to an upstream change in GitHub Actions or Cygwin's handling of the $HOME variable, causing nvm to be installed in a different location than expected.

The workflow was encountering:

  • File not found errors when trying to source $HOME/.nvm/nvm.sh
  • nvm: command not found errors in subsequent commands

Solution

This PR fixes the issue by ensuring nvm is installed and sourced from the correct path in the Cygwin environment:

  1. Set HOME explicitly: Added export HOME="$(cygpath -u "$USERPROFILE")" to set the HOME variable to the Windows user directory using Cygwin's cygpath utility
  2. Added debug output: Added echo "HOME is $HOME" to verify the HOME location is correct
  3. Added verification: Added ls -l $HOME/.nvm to confirm the nvm directory exists in the expected location

Changes Made

cat >~/setup.sh <<EOM
  unset npm_config_prefix
  export NVM_INSTALL_GITHUB_REPO="$NVM_INSTALL_GITHUB_REPO"
  export NVM_INSTALL_VERSION="$NVM_INSTALL_VERSION"
+ export HOME="$(cygpath -u "$USERPROFILE")"

+ echo "HOME is $HOME"
  curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
+ ls -l $HOME/.nvm
  . "$HOME/.nvm/nvm.sh"
  nvm install --lts

These minimal changes ensure that:

  • The $HOME variable points to the correct Windows user directory in Cygwin
  • nvm is installed in the expected location ($HOME/.nvm/)
  • The workflow can successfully source nvm.sh and execute nvm commands
  • Debug output helps verify the installation path is correct

This resolves the file not found and nvm: command not found errors under Cygwin on GitHub Actions.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@ljharb ljharb marked this pull request as ready for review July 3, 2025 19:47
Copilot AI changed the title [WIP] Fix Cygwin nvm install path in GitHub Actions workflow to set HOME correctly Fix Cygwin workflow HOME variable to resolve nvm installation path issues Jul 3, 2025
Copilot AI requested a review from ljharb July 3, 2025 19:47
Copilot finished work on behalf of ljharb July 3, 2025 19:47
@ljharb ljharb changed the title Fix Cygwin workflow HOME variable to resolve nvm installation path issues [actions] Fix Cygwin workflow HOME variable to resolve nvm installation path issues Jul 3, 2025
@ljharb ljharb force-pushed the copilot/fix-8ef89578-ccbd-4ee7-ac81-d932c26324eb branch 2 times, most recently from 6a50b29 to 0215ef8 Compare July 3, 2025 20:04
@ljharb ljharb merged commit 0215ef8 into master Jul 3, 2025
362 of 366 checks passed
@ljharb ljharb deleted the copilot/fix-8ef89578-ccbd-4ee7-ac81-d932c26324eb branch July 3, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants