mirror of
https://github.com/block/goose.git
synced 2026-10-14 03:42:43 +00:00
fix(installer): write PATH to login shell files, idempotently (#12072)
Some checks are pending
Canary / Prepare Version (push) Waiting to run
Canary / build-cli-linux (push) Blocked by required conditions
Canary / Upload Install Script (push) Waiting to run
Canary / bundle-macos-arm64 (push) Blocked by required conditions
Canary / bundle-macos-x64 (push) Blocked by required conditions
Canary / bundle-windows (push) Blocked by required conditions
Canary / bundle-windows-cuda (push) Blocked by required conditions
Canary / Release (push) Blocked by required conditions
CI / changes (push) Waiting to run
CI / goose ACP npm packages (push) Blocked by required conditions
CI / Check Rust Code Format (push) Blocked by required conditions
CI / Build and Test Rust Project (push) Blocked by required conditions
CI / Check goose-sdk UniFFI (push) Blocked by required conditions
CI / Test Kotlin GDK package (push) Blocked by required conditions
CI / Build and Test TLS Backend (native-tls) (push) Blocked by required conditions
CI / Build and Test TLS Backend (rustls-tls) (push) Blocked by required conditions
CI / Build and Test Roaming Feature (push) Blocked by required conditions
CI / Build Rust Project on Windows (push) Waiting to run
CI / Check MSRV (push) Blocked by required conditions
CI / Lint Rust Code (push) Blocked by required conditions
CI / Check Generated Schemas are Up-to-Date (push) Blocked by required conditions
CI / Check GDK Release Configuration (push) Waiting to run
CI / Check GDK API Reference is Up-to-Date (push) Waiting to run
CI / Test and Lint Electron Desktop App (push) Blocked by required conditions
CI / Test Desktop Updater Install (ubuntu-latest) (push) Blocked by required conditions
CI / Test Desktop Updater Install (windows-latest) (push) Blocked by required conditions
MCP Conformance / Build Conformance Binaries (push) Waiting to run
MCP Conformance / Conformance 2025-11-25 / 0.1.16 (push) Blocked by required conditions
MCP Conformance / Conformance 2025-11-25 / 0.2.0-alpha.10 (push) Blocked by required conditions
MCP Conformance / Conformance 2026-07-28 / 0.2.0-alpha.10 (push) Blocked by required conditions
Create Minor Release PR / check-version-bump-pr (push) Waiting to run
Create Minor Release PR / release (push) Blocked by required conditions
Live Provider Tests / check-fork (push) Waiting to run
Live Provider Tests / changes (push) Blocked by required conditions
Live Provider Tests / Build Binary (push) Blocked by required conditions
Live Provider Tests / Smoke Tests (push) Blocked by required conditions
Publish Docker Image / docker (push) Waiting to run
Live Provider Tests / Smoke Tests (Code Execution) (push) Blocked by required conditions
Live Provider Tests / Compaction Tests (push) Blocked by required conditions
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Some checks are pending
Canary / Prepare Version (push) Waiting to run
Canary / build-cli-linux (push) Blocked by required conditions
Canary / Upload Install Script (push) Waiting to run
Canary / bundle-macos-arm64 (push) Blocked by required conditions
Canary / bundle-macos-x64 (push) Blocked by required conditions
Canary / bundle-windows (push) Blocked by required conditions
Canary / bundle-windows-cuda (push) Blocked by required conditions
Canary / Release (push) Blocked by required conditions
CI / changes (push) Waiting to run
CI / goose ACP npm packages (push) Blocked by required conditions
CI / Check Rust Code Format (push) Blocked by required conditions
CI / Build and Test Rust Project (push) Blocked by required conditions
CI / Check goose-sdk UniFFI (push) Blocked by required conditions
CI / Test Kotlin GDK package (push) Blocked by required conditions
CI / Build and Test TLS Backend (native-tls) (push) Blocked by required conditions
CI / Build and Test TLS Backend (rustls-tls) (push) Blocked by required conditions
CI / Build and Test Roaming Feature (push) Blocked by required conditions
CI / Build Rust Project on Windows (push) Waiting to run
CI / Check MSRV (push) Blocked by required conditions
CI / Lint Rust Code (push) Blocked by required conditions
CI / Check Generated Schemas are Up-to-Date (push) Blocked by required conditions
CI / Check GDK Release Configuration (push) Waiting to run
CI / Check GDK API Reference is Up-to-Date (push) Waiting to run
CI / Test and Lint Electron Desktop App (push) Blocked by required conditions
CI / Test Desktop Updater Install (ubuntu-latest) (push) Blocked by required conditions
CI / Test Desktop Updater Install (windows-latest) (push) Blocked by required conditions
MCP Conformance / Build Conformance Binaries (push) Waiting to run
MCP Conformance / Conformance 2025-11-25 / 0.1.16 (push) Blocked by required conditions
MCP Conformance / Conformance 2025-11-25 / 0.2.0-alpha.10 (push) Blocked by required conditions
MCP Conformance / Conformance 2026-07-28 / 0.2.0-alpha.10 (push) Blocked by required conditions
Create Minor Release PR / check-version-bump-pr (push) Waiting to run
Create Minor Release PR / release (push) Blocked by required conditions
Live Provider Tests / check-fork (push) Waiting to run
Live Provider Tests / changes (push) Blocked by required conditions
Live Provider Tests / Build Binary (push) Blocked by required conditions
Live Provider Tests / Smoke Tests (push) Blocked by required conditions
Publish Docker Image / docker (push) Waiting to run
Live Provider Tests / Smoke Tests (Code Execution) (push) Blocked by required conditions
Live Provider Tests / Compaction Tests (push) Blocked by required conditions
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Signed-off-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
parent
2090ad1c65
commit
e629eea1dd
1 changed files with 66 additions and 7 deletions
|
|
@ -392,6 +392,58 @@ if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then
|
|||
else
|
||||
SHELL_NAME=$(basename "$SHELL")
|
||||
|
||||
# Appends an export line to a file only if that file does not already
|
||||
# put $GOOSE_BIN_DIR on the PATH, so re-running the installer is idempotent.
|
||||
# Only active (non-comment) lines that set PATH and contain the directory
|
||||
# as a complete path entry count; a commented-out old export or a longer
|
||||
# sibling path (e.g. ".local/bin-old") must not suppress the append.
|
||||
GOOSE_BIN_DIR_RE=$(printf '%s' "$GOOSE_BIN_DIR" | sed 's/[.[\*^$()+?{|]/\\&/g')
|
||||
add_path_line() {
|
||||
file="$1"
|
||||
line="$2"
|
||||
mkdir -p "$(dirname "$file")"
|
||||
if [ -f "$file" ] && grep -v '^[[:space:]]*#' "$file" | grep -i "path" | grep -Eq "(^|[=:\"' ])$GOOSE_BIN_DIR_RE([:\"' ]|\$)"; then
|
||||
echo "$file already references $GOOSE_BIN_DIR, skipping."
|
||||
else
|
||||
echo "$line" >> "$file"
|
||||
echo "Added \$GOOSE_BIN_DIR to $file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Pick the file(s) to update for the user's login shell.
|
||||
# POSIX_LOGIN_FILE is read by login shells, desktop launchers, ssh, cron;
|
||||
# RC_FILE (when set) is read by interactive shells.
|
||||
EXPORT_LINE="export PATH=\"$GOOSE_BIN_DIR:\$PATH\""
|
||||
case "$SHELL_NAME" in
|
||||
bash)
|
||||
# Bash login shells read the first existing file of ~/.bash_profile,
|
||||
# ~/.bash_login, ~/.profile — mirror that lookup order here.
|
||||
if [ -f "$HOME/.bash_profile" ]; then
|
||||
POSIX_LOGIN_FILE="$HOME/.bash_profile"
|
||||
elif [ -f "$HOME/.bash_login" ]; then
|
||||
POSIX_LOGIN_FILE="$HOME/.bash_login"
|
||||
else
|
||||
POSIX_LOGIN_FILE="$HOME/.profile"
|
||||
fi
|
||||
RC_FILE="$HOME/.bashrc"
|
||||
;;
|
||||
zsh)
|
||||
POSIX_LOGIN_FILE=""
|
||||
RC_FILE="$HOME/.zshrc"
|
||||
;;
|
||||
fish)
|
||||
POSIX_LOGIN_FILE=""
|
||||
# fish reads config from $XDG_CONFIG_HOME/fish when that is set.
|
||||
RC_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish"
|
||||
EXPORT_LINE="fish_add_path \"$GOOSE_BIN_DIR\""
|
||||
;;
|
||||
*)
|
||||
# sh, dash, and anything else POSIX-ish: ~/.profile is the standard file.
|
||||
POSIX_LOGIN_FILE="$HOME/.profile"
|
||||
RC_FILE=""
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "The \$GOOSE_BIN_DIR is not in your PATH."
|
||||
|
||||
|
|
@ -414,16 +466,23 @@ if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then
|
|||
|
||||
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."
|
||||
if [ -n "$POSIX_LOGIN_FILE" ]; then
|
||||
add_path_line "$POSIX_LOGIN_FILE" "$EXPORT_LINE"
|
||||
fi
|
||||
if [ -n "$RC_FILE" ]; then
|
||||
add_path_line "$RC_FILE" "$EXPORT_LINE"
|
||||
fi
|
||||
echo "Done! Start a new shell or log in again 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."
|
||||
if [ -n "$POSIX_LOGIN_FILE" ] && [ -n "$RC_FILE" ]; then
|
||||
echo "Add it to your PATH by adding this line to $POSIX_LOGIN_FILE and $RC_FILE:"
|
||||
else
|
||||
echo "Add it to your PATH by adding this line to ${POSIX_LOGIN_FILE:-$RC_FILE}:"
|
||||
fi
|
||||
echo " $EXPORT_LINE"
|
||||
echo "Then start a new shell or log in again to apply changes."
|
||||
;;
|
||||
*)
|
||||
echo "Invalid choice. Please add \$GOOSE_BIN_DIR to your PATH manually."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue