Repository navigation
Conversation
…ctory download_cli.sh installs to $USERPROFILE/goose on native Windows, but its PATH warning and the Git Bash/MSYS2 docs pointed users at .local/bin, so following them left the CLI undiscoverable. The PowerShell snippet it printed had also lost its quotes, and the PATH check compared a Windows path against Git Bash's POSIX PATH, so it warned even when the directory was already on PATH. - Compare and print both the POSIX and Windows forms of GOOSE_BIN_DIR (via cygpath) - Print Git Bash/MSYS2, PowerShell profile and Windows user PATH commands for the actual install directory, including a custom GOOSE_BIN_DIR - Document the per-installer defaults and that shell profiles do not affect apps started outside the shell Fixes aaif-goose#13697
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7eb99bbb8f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| echo " echo 'export PATH=\"$GOOSE_BIN_DIR_POSIX:\$PATH\"' >> ~/.bashrc" | ||
| echo " source ~/.bashrc" |
There was a problem hiding this comment.
Persist the Git Bash PATH change for login shells
When this command is followed from a login Bash session whose ~/.bash_profile or ~/.profile does not source ~/.bashrc, it persists the export only in .bashrc and sources it in the current session; later login shells read the login profile instead, so goose is missing again. Add the entry to the active login profile or ensure it sources .bashrc.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 353d5c5. When the user's bash login file (~/.bash_profile, ~/.bash_login or ~/.profile, first one found) exists and doesn't load ~/.bashrc, the installer now also prints the export line for that file. When none of them exists, Git for Windows creates a ~/.bash_profile that loads ~/.bashrc (/etc/profile.d/bash_profile.sh), so ~/.bashrc alone is enough there. Verified in Git Bash: with a .bash_profile that doesn't source .bashrc, a new login shell couldn't find goose before and finds it after.
| echo "# Reload profile or restart PowerShell" | ||
| echo '. $PROFILE' | ||
| echo " if (!(Test-Path \$PROFILE)) { New-Item -Path \$PROFILE -ItemType File -Force }" | ||
| echo " Add-Content -Path \$PROFILE -Value '\$env:PATH = \"$GOOSE_BIN_DIR_WIN;\$env:PATH\"'" |
There was a problem hiding this comment.
Escape Windows paths before embedding them in PowerShell quotes
For a valid Windows install directory containing a single quote, this emits the path verbatim inside a PowerShell single-quoted string, which terminates the string and makes the suggested profile command unparsable; the user-PATH command has the same issue. Escape the path for PowerShell before printing these snippets.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 353d5c5. Single quotes in the install directory are now escaped for both the bash snippet ('\'') and the PowerShell snippets (''). Verified with a directory named O'Brien bin: the printed Git Bash command and the PowerShell profile line both resolve goose in a new shell, and the user PATH command parses with no errors.
- Also print the export line for the user's bash login file when it exists and does not load ~/.bashrc, so login shells pick up the PATH change - Escape single quotes in the install directory for the bash and PowerShell snippets
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 353d5c5e3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # The snippets below wrap the directory in single quotes; escape any it contains. | ||
| GOOSE_BIN_DIR_SH=$(printf '%s' "$GOOSE_BIN_DIR_POSIX" | sed "s/'/'\\\\''/g") | ||
| GOOSE_BIN_DIR_PS=$(printf '%s' "$GOOSE_BIN_DIR_WIN" | sed "s/'/''/g") | ||
| WINDOWS_EXPORT_LINE="export PATH=\"$GOOSE_BIN_DIR_SH:\$PATH\"" |
There was a problem hiding this comment.
Keep PATH directories literal in the printed shell snippets
The new quoting only escapes apostrophes: when a valid custom GOOSE_BIN_DIR contains $, backticks, or $(), this line writes it into a double-quoted Bash assignment, and the PowerShell profile snippet does likewise. Sourcing either suggested profile then expands those characters, corrupting the PATH entry and potentially executing the command substitution. Keep the directory literal for each target shell before printing these snippets.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b75e310. The lines written to ~/.bashrc and the PowerShell profile now keep the directory in single quotes (export PATH='<dir>':"$PATH" and $env:PATH = '<dir>;' + $env:PATH), so nothing in it gets expanded when the profile loads. The printed echo and Add-Content commands escape it for their own quoting.
Tested in Git Bash with GOOSE_BIN_DIR set to .../x $HOME `touch PWNED` y. Before, opening a new shell ran the touch and goose wasn't found. Now ~/.bashrc gets the literal path, nothing runs, and goose resolves. Same in PowerShell 5.1: the old profile line broke the path, and the new one resolves goose.exe. I also re-ran the earlier cases (an O'Brien dir, a .bash_profile that doesn't source .bashrc, and the default dir).
…pets The lines the installer suggests adding to ~/.bashrc and the PowerShell profile put the directory inside double quotes, so a GOOSE_BIN_DIR with $, backticks or $() was expanded every time the profile loaded. Write the directory in single quotes instead, and escape it for the echo and Add-Content commands that print those lines.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b75e310f6d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # ~/.bash_profile that loads ~/.bashrc only when none of them exists. | ||
| for login_file in .bash_profile .bash_login .profile; do | ||
| if [ -f "$HOME/$login_file" ]; then | ||
| if ! grep -q "bashrc" "$HOME/$login_file"; then |
There was a problem hiding this comment.
Check whether the login profile actively sources bashrc
If the first existing Bash login profile mentions bashrc only in a comment or unrelated text but does not source ~/.bashrc, this guard suppresses the login-file export; it only updates ~/.bashrc, so a later login shell can still miss goose. The new guard checks only for the substring bashrc, not an active source line, so the earlier login-profile fix does not cover this case.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch. Fixed in c8dd6d5: the check now skips comment lines and only counts an active source/. line that loads bashrc. With a .bash_profile that mentions bashrc only in a comment, the installer now prints the export line for it, and a new login shell finds goose. The usual forms (. ~/.bashrc, source "$HOME/.bashrc", the Git for Windows default) still print nothing extra.
| echo "terminal and in apps started outside of it, add it to your Windows user PATH" | ||
| echo "from PowerShell, then open a new terminal:" | ||
| echo "" | ||
| echo " [Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';$GOOSE_BIN_DIR_PS', 'User')" |
There was a problem hiding this comment.
Escape the directory in the user-PATH PowerShell command
The profile command now uses PS_PROFILE_ARG, but this separate user-PATH command still interpolates raw GOOSE_BIN_DIR_PS. For a valid install directory containing an apostrophe, such as O'Brien, the generated path terminates the PowerShell single-quoted string early and the suggested SetEnvironmentVariable command fails to parse; escape the path for PowerShell here too.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This one is already escaped: GOOSE_BIN_DIR_PS is the path after sed "s/'/''/g" (line 394), so O'Brien comes out as O''Brien in that command. Only the profile line needs PS_PROFILE_ARG, because it has a second layer of quotes. I checked it with PowerShell's parser: no errors, and the value ends in \O'Brien bin.
| GOOSE_BIN_DIR_PS=$(printf '%s' "$GOOSE_BIN_DIR_WIN" | sed "s/'/''/g") | ||
| WINDOWS_EXPORT_LINE="export PATH='$GOOSE_BIN_DIR_SH':\"\$PATH\"" | ||
| # The printed command passes that line to echo in double quotes. | ||
| WINDOWS_EXPORT_ARG=$(printf '%s' "$WINDOWS_EXPORT_LINE" | sed 's/[\\$`"]/\\&/g') |
There was a problem hiding this comment.
Escape history expansion in the Git Bash command
When a valid custom GOOSE_BIN_DIR contains ! and a user pastes the printed Git Bash command into an interactive shell, the exclamation mark remains unescaped inside the command's outer double quotes. Bash performs history expansion there, so a path such as goose!dir can produce event not found or expand to a different path instead of updating PATH; escape ! or use a paste-safe quoting form.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c8dd6d5. Each ! is now printed as "'!'", outside the double quotes, so pasting the command doesn't trigger history expansion. The default output is unchanged. Tested by pasting into an interactive bash with a goose!dir folder: before, it failed with event not found and wrote nothing. Now ~/.bashrc gets the literal path and goose resolves in a new shell.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8dd6d56f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for login_file in .bash_profile .bash_login .profile; do | ||
| if [ -f "$HOME/$login_file" ]; then | ||
| # Only an active line that sources ~/.bashrc counts, not a comment. | ||
| if ! grep -v '^[[:space:]]*#' "$HOME/$login_file" | grep -Eq '(^|[;&|{[:space:]])(source|\.)[[:space:]]+[^#]*bashrc'; then |
There was a problem hiding this comment.
Anchor the login-profile check to an actual source command
When the first existing login profile contains an informational line such as echo Remember to source ~/.bashrc rather than sourcing it, this regex still matches source after whitespace, so the installer omits the login-file command and tells the user only to append to and source ~/.bashrc; a later login shell reads the profile but not that rc, leaving goose unavailable. The fresh evidence is that the added guard filters only full-line comments and does not anchor source/. to a shell command position, despite the comment claiming it checks for an active ~/.bashrc source.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I'll leave this one as is. A login profile that mentions source ~/.bashrc inside an echo without actually sourcing it seems very unlikely, and fully parsing shell syntax isn't worth it for a hint the installer only prints. The common cases are covered: comments, . ~/.bashrc, source inside an if, and the Git for Windows default.
jamadeo
left a comment
There was a problem hiding this comment.
🤖 Preserving both installers’ defaults is the right call, and the native Windows testing is helpful. Two cases still need attention:
- P2 — Resolve relative
GOOSE_BIN_DIRvalues before printing persistent PATH commands.cygpath -uandcygpath -wconvert formats but don’t request an absolute path. An install withGOOSE_BIN_DIR='./custom bin'can succeed and then emit a PATH entry that depends on the shell’s working directory. Usecygpath -a -uandcygpath -a -w, and verify the printed commands from a different working directory. - P2 — The Git Bash/MSYS2 docs still give a
.bashrc-only recipe. It works immediately because the recipe sources.bashrc, but a fresh login shell with an existing.bash_profilethat doesn’t source.bashrcwon’t see the change. Since the installer already accounts for the common login-profile case, please point readers to its generated commands rather than maintain a second recipe.
Please verify both cases on the final revision, including a fresh login shell rather than only a fresh interactive Bash session.
|
Thanks for the review! Both are done in b6f5c88.
Tested on this revision in Git Bash on Windows, with an isolated HOME whose |
Closes #13697
Summary
On native Windows,
download_cli.shinstalls to$USERPROFILE/goose, but its PATH warning and the Git Bash/MSYS2 docs pointed to.local/bin, so following either left the CLI undiscoverable. While reproducing it in Git Bash I found two related problems in the same warning:C:\Users\me/goose) against Git Bash's POSIXPATH(/c/Users/me/goose), so it warned even when the directory was already onPATH.-Value $env:PATH = "..."), so it was not a valid command.Following the guidance on the issue, both installers keep their current default locations. Only the PATH guidance changes:
download_cli.shconvertsGOOSE_BIN_DIRwithcygpathand comparesPATHagainst both forms.GOOSE_BIN_DIR. It also notes that shell profiles don't affect apps started outside that shell.download_cli.ps1and the WSL instructions are unchanged.Testing
Native Windows 11, Git Bash (MINGW64), installing goose 1.60.2 into a sandboxed
USERPROFILE/HOMEwithCONFIGURE=false:%USERPROFILE%\.local\bin(wrong dir), PowerShell only, broken quoting...\goosegoose --versionworks)GOOSE_BIN_DIRwith a space (.../custom bin).local\bin.../custom binThen I ran the printed commands:
bashresolvedgoosefrom the install dir, for both the default dir and the custom dir with a space.$(cygpath -u "$USERPROFILE")/goose) in a clean profile. A fresh shell resolvedgoose.Add-Contentline against a test profile in Windows PowerShell 5.1. A newpowershell -NoProfilethat dot-sourced it resolvedgoose.exefrom the custom dir.Not tested: MSYS2 and Cygwin. Both ship
cygpath, and if it's missing the script falls back to the previous comparison. I also didn't build the docs site.Before (default dir, Git Bash):
After:
Related Issues
Discussion: #13581 (related; this PR does not rename executables)