-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: show PowerShell PATH instructions for Windows users #4989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,12 +237,58 @@ else | |
| echo "Skipping 'goose configure', you may need to run this manually later" | ||
| fi | ||
|
|
||
|
|
||
|
|
||
| # --- 7) Check PATH and give instructions if needed --- | ||
| if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then | ||
| echo "" | ||
| echo "Warning: goose installed, but $GOOSE_BIN_DIR is not in your PATH." | ||
| echo "Add it to your PATH by editing ~/.bashrc, ~/.zshrc, or similar:" | ||
| echo " export PATH=\"$GOOSE_BIN_DIR:\$PATH\"" | ||
| echo "Then reload your shell (e.g. 'source ~/.bashrc', 'source ~/.zshrc') to apply changes." | ||
|
|
||
| if [ "$OS" = "windows" ]; then | ||
| echo "To add goose to your PATH in PowerShell:" | ||
| echo "" | ||
| echo "# Add to your PowerShell profile" | ||
| echo '$profilePath = $PROFILE' | ||
| echo 'if (!(Test-Path $profilePath)) { New-Item -Path $profilePath -ItemType File -Force }' | ||
| echo 'Add-Content -Path $profilePath -Value ''$env:PATH = "$env:USERPROFILE\.local\bin;$env:PATH"''' | ||
| echo "# Reload profile or restart PowerShell" | ||
| echo '. $PROFILE' | ||
| echo "" | ||
| echo "Alternatively, you can run:" | ||
| echo " goose configure" | ||
| echo "or rerun this install script after updating your PATH." | ||
| else | ||
| SHELL_NAME=$(basename "$SHELL") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scope expanded a bit on this PR and feels like one we'd want to now test a bit on different envs/shells to make sure there are no hitches. Either that or we go back to only adding the improvement for windows, which I think was great as it was after iterations with @iandouglas ! |
||
|
|
||
| echo "" | ||
| echo "The \$GOOSE_BIN_DIR is not in your PATH." | ||
| echo "What would you like to do?" | ||
| echo "1) Add it for me" | ||
| echo "2) I'll add it myself, show instructions" | ||
|
|
||
| read -p "Enter choice [1/2]: " choice | ||
|
|
||
| case "$choice" in | ||
| 1) | ||
| RC_FILE="$HOME/.${SHELL_NAME}rc" | ||
| echo "Adding \$GOOSE_BIN_DIR to $RC_FILE..." | ||
| echo "export PATH=\"$GOOSE_BIN_DIR:\$PATH\"" >> "$RC_FILE" | ||
| echo "Done! Reload your shell or run 'source $RC_FILE' to apply changes." | ||
| ;; | ||
| 2) | ||
| echo "" | ||
| echo "Add it to your PATH by editing ~/.${SHELL_NAME}rc or similar:" | ||
| echo " export PATH=\"$GOOSE_BIN_DIR:\$PATH\"" | ||
| echo "Then reload your shell (e.g. 'source ~/.${SHELL_NAME}rc') to apply changes." | ||
| ;; | ||
| *) | ||
| echo "Invalid choice. Please add \$GOOSE_BIN_DIR to your PATH manually." | ||
| ;; | ||
| esac | ||
| fi | ||
|
|
||
| echo "" | ||
| fi | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment here -- you're presenting this 'alternative' on line 256 and 264 almost like it's something they can do INSTEAD of modifying their path? How does running 'goose configure' help set up their PATH on their behalf if this download script couldn't do it?
I kinda feel like we could get more intelligent here, where we just prompt the user "hey do you want me to add the goose installation folder to your PATH environment" and just go run these commands or a an
echo "export PATH=/goose/bin/etc:$PATH" >> ~/.bashrcbecause we could determine from$SHELLwhich shell they're using on a Mac/Linux system.maybe something like:
The $GOOSE_BIN_DIR is not in your path, what would you like to do:
and then if they're on Linux/Mac we could prompt them regardless of their choice:
We think you're using$SHELL, should we add it to ~/.$ (basename $SHELL)rc for you?