fix: handle missing cygpath when Git Bash invoked from PowerShell#60
Conversation
When install.ps1 invokes Git Bash non-interactively (& bash.exe script), /etc/profile isn't sourced and cygpath may not be on PATH. The fallback `echo "$USERPROFILE"` passes the raw MSYS2 POSIX path (/c/Users/...) which Docker can't resolve because MSYS_NO_PATHCONV=1 suppresses automatic conversion. Two-pronged fix: - install.ps1: add --login so bash sources /etc/profile (primary fix) - install.sh: add manual POSIX-to-mixed-mode fallback when cygpath is unavailable (/c/Users/... → C:/Users/...), as defense in depth Also reuse the already-resolved USER_HOME for the git config fallback path instead of calling cygpath a second time. https://claude.ai/code/session_01GMPR7m8zbe6WTF7qQf6N8y
Users may try `irm ... | iex -Edge` expecting it to pass -Edge to the downloaded script, but PowerShell interprets it as an argument to Invoke-Expression. Add a note explaining the limitation and show the local .\install.ps1 form for -Edge and -Verbose. https://claude.ai/code/session_01GMPR7m8zbe6WTF7qQf6N8y
There was a problem hiding this comment.
Pull request overview
This PR improves Windows installation reliability when install.ps1 invokes Git Bash non-interactively, ensuring MSYS2 tooling (notably cygpath) is available and providing a defensive path conversion fallback in install.sh when it isn’t.
Changes:
- Invoke Git Bash with
--loginfrominstall.ps1so/etc/profileis sourced and MSYS2 utilities are onPATH. - Add a manual Windows/MSYS path-to-mixed-mode fallback in
install.shwhencygpathis unavailable. - Update README Windows instructions to clarify re-running locally for
-Edge/-Verboseflags.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Clarifies PowerShell install usage and how to pass flags after initial install. |
| install.sh | Adds cygpath-missing fallback path conversion and reuses resolved USER_HOME for gitconfig lookup. |
| install.ps1 | Runs Git Bash with --login to ensure /etc/profile is sourced in non-interactive invocation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| USER_HOME="${USERPROFILE//\\//}" | ||
| # /c/Users/... → C:/Users/... | ||
| if [[ "$USER_HOME" =~ ^/([a-zA-Z])(/.*)$ ]]; then | ||
| USER_HOME="${BASH_REMATCH[1]^}:${BASH_REMATCH[2]}" |
There was a problem hiding this comment.
USER_HOME="${BASH_REMATCH[1]^}:..." uses the ${var^} uppercase expansion, which requires Bash 4+. Since this installer is invoked on macOS via | bash (often Bash 3.2), this introduces a compatibility risk ("bad substitution") if the conversion branch is hit. Consider dropping the uppercasing (drive letter case is irrelevant) or using a Bash-3-compatible approach (e.g., tr) so the script remains portable.
| USER_HOME="${BASH_REMATCH[1]^}:${BASH_REMATCH[2]}" | |
| USER_HOME="$(printf '%s' "${BASH_REMATCH[1]}" | tr '[:lower:]' '[:upper:]'):${BASH_REMATCH[2]}" |
When install.ps1 invokes Git Bash non-interactively (& bash.exe script),
/etc/profile isn't sourced and cygpath may not be on PATH. The fallback
echo "$USERPROFILE"passes the raw MSYS2 POSIX path (/c/Users/...)which Docker can't resolve because MSYS_NO_PATHCONV=1 suppresses
automatic conversion.
Two-pronged fix:
unavailable (/c/Users/... → C:/Users/...), as defense in depth
Also reuse the already-resolved USER_HOME for the git config fallback
path instead of calling cygpath a second time.
https://claude.ai/code/session_01GMPR7m8zbe6WTF7qQf6N8y