Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(installer): configure a login-mode startup file for bash

jkomynoaaf2d250cfb9
diff --git a/INSTALL.md b/INSTALL.md
index 2ab84efd7..188f2f8a5 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -6,7 +6,7 @@ Install the CLI bundle in `~/.composio` and its entry point in `~/.local/bin`:
curl -fsSL https://composio.dev/install | sh
```
-The installer also configures your shell. It infers your login shell from `$SHELL` (`zsh`, `bash`, or `fish`) and writes a managed `# Composio CLI` PATH block so future terminals find `composio`. For `zsh` and `fish`, it updates the matching startup file. For `bash`, it updates `~/.bashrc` and the first existing login override, `~/.bash_profile` or `~/.bash_login`. Open a new terminal, then run `composio login`.
+The installer also configures your shell. It infers your login shell from `$SHELL` (`zsh`, `bash`, or `fish`) and writes a managed `# Composio CLI` PATH block so future terminals find `composio`. For `zsh` and `fish`, it updates the matching startup file. For `bash`, it updates `~/.bashrc` plus a login-mode startup file, because a login bash (what macOS Terminal.app starts) never reads `~/.bashrc`: the first existing of `~/.bash_profile` or `~/.bash_login`, or a newly created `~/.bash_profile` when neither exists. A `~/.bash_profile` created this way sources `~/.profile` first, so nothing you already had stops loading; `~/.profile` itself is never modified. Open a new terminal, then run `composio login`.
If your shell is not recognized, or shell setup fails, the binary install still succeeds and the installer prints a runnable command instead. The installer does not install agent plugins or log you in unless you ask it to.
diff --git a/docs/content/docs/cli.mdx b/docs/content/docs/cli.mdx
index 10dcc580c..942cb2968 100644
--- a/docs/content/docs/cli.mdx
+++ b/docs/content/docs/cli.mdx
@@ -16,7 +16,7 @@ Install the CLI with one command:
curl -fsSL https://composio.dev/install | sh
```
-The installer downloads and verifies the release bundle in `~/.composio`, creates the `~/.local/bin/composio` entry point, and configures your shell so future terminals find `composio` on `PATH`. It recognizes `zsh`, `bash`, and `fish` login shells from `$SHELL` and writes a managed `# Composio CLI` block to their startup files. `bash` also updates the first existing login override, `~/.bash_profile` or `~/.bash_login`. If your shell is not recognized, or shell setup fails, the CLI still installs and the installer prints a runnable command instead. It does not install agent plugins or log you in unless you ask it to. To skip shell configuration entirely, see [Shell setup overrides](#shell-setup-overrides).
+The installer downloads and verifies the release bundle in `~/.composio`, creates the `~/.local/bin/composio` entry point, and configures your shell so future terminals find `composio` on `PATH`. It recognizes `zsh`, `bash`, and `fish` login shells from `$SHELL` and writes a managed `# Composio CLI` block to their startup files. `bash` also gets a login-mode startup file — the first existing of `~/.bash_profile` or `~/.bash_login`, or a newly created `~/.bash_profile` — because a login bash, which macOS Terminal.app starts, never reads `~/.bashrc`. If your shell is not recognized, or shell setup fails, the CLI still installs and the installer prints a runnable command instead. It does not install agent plugins or log you in unless you ask it to. To skip shell configuration entirely, see [Shell setup overrides](#shell-setup-overrides).
Open a new terminal, then log in:
@@ -80,7 +80,7 @@ This configures `~/.zshrc` and delegates setup to `composio install --shell zsh`
curl -fsSL https://composio.dev/install | COMPOSIO_INSTALL_SHELL=bash sh
```
-This configures `~/.bashrc` and delegates setup to `composio install --shell bash`. If `~/.bash_profile` or `~/.bash_login` exists, it also updates the first active login file so `bash -ilc` can find `composio`.
+This configures `~/.bashrc` and delegates setup to `composio install --shell bash`. It also configures a login-mode startup file so `bash -ilc` can find `composio`: the first active login file (`~/.bash_profile`, then `~/.bash_login`), or a new `~/.bash_profile` that sources your existing `~/.profile` when neither exists.
</Tab>
<Tab value="fish">
```bash
diff --git a/install.sh b/install.sh
index bb3c47228..2039486a2 100755
--- a/install.sh
+++ b/install.sh
@@ -29,6 +29,19 @@ debug() {
fi
}
+# Replays a captured subprocess log on the debug channel. The installer owns
+# its own presentation, so delegated output is suppressed by default and stays
+# available for troubleshooting through COMPOSIO_DEBUG.
+debug_captured_output() {
+ debug_captured_label=$1
+ debug_captured_file=$2
+ if ! is_true "${COMPOSIO_DEBUG:-}" || [ ! -s "$debug_captured_file" ]; then
+ return 0
+ fi
+ debug "$debug_captured_label"
+ sed 's/^/+ /' "$debug_captured_file" >&2 || :
+}
+
tildify() {
case $1 in
"$HOME"/*) printf '%s/%s\n' '~' "${1#"$HOME"/}" ;;
@@ -410,6 +423,54 @@ write_path_block() {
return 0
}
+# Names the bash startup file a login shell reads the managed block from.
+# A login bash reads /etc/profile and then only the first existing of
+# ~/.bash_profile, ~/.bash_login, ~/.profile; it never reads ~/.bashrc, and
+# macOS Terminal.app starts exactly such a shell. An override that already
+# exists is reused; otherwise ~/.bash_profile is the file to create. ~/.profile
+# is never a target: every POSIX shell shares it.
+bash_login_path_file() {
+ if [ ! -f "$HOME/.bash_profile" ] && [ -f "$HOME/.bash_login" ]; then
+ printf '%s\n' "$HOME/.bash_login"
+ else
+ printf '%s\n' "$HOME/.bash_profile"
+ fi
+}
+
+# Single source of truth for the startup files the managed PATH block lands in,
+# in write order. Both setup paths and the confirmation message read it, so the
+# files the installer configures are exactly the files it verifies and names.
+shell_path_files() {
+ case $1 in
+ zsh) printf '%s\n' "$HOME/.zshrc" ;;
+ fish) printf '%s\n' "$HOME/.config/fish/config.fish" ;;
+ bash) printf '%s\n' "$HOME/.bashrc" "$(bash_login_path_file)" ;;
+ *) return 1 ;;
+ esac
+}
+
+# A ~/.bash_profile the installer creates shadows an existing ~/.profile, which
+# login bash read while no override existed. Seed the new file so it keeps
+# sourcing it; ~/.profile itself is left untouched.
+seed_bash_login_file() {
+ seed_login_shell=$1
+ seed_login_file=$2
+ if [ "$seed_login_shell" != bash ] || [ "$seed_login_file" != "$HOME/.bash_profile" ]; then
+ return 0
+ fi
+ if [ -e "$seed_login_file" ] || [ ! -f "$HOME/.profile" ]; then
+ return 0
+ fi
+ cat >"$seed_login_file" 2>/dev/null <<'SEED_BASH_LOGIN_FILE' || return 1
+# Created by the Composio CLI installer.
+# Bash reads this file instead of ~/.profile in login shells.
+if [ -f "$HOME/.profile" ]; then
+ . "$HOME/.profile"
+fi
+SEED_BASH_LOGIN_FILE
+ return 0
+}
+
inline_shell_setup() {
inline_setup_shell=$1
inline_setup_bin_dir=$2
@@ -417,21 +478,20 @@ inline_shell_setup() {
return 1
fi
inline_setup_rendered=$(render_bin_dir "$inline_setup_bin_dir")
- case $inline_setup_shell in
- zsh) write_path_block "$HOME/.zshrc" zsh "$inline_setup_rendered" || return 1 ;;
- fish) write_path_block "$HOME/.config/fish/config.fish" fish "$inline_setup_rendered" || return 1 ;;
- bash)
- inline_setup_status=0
- write_path_block "$HOME/.bashrc" bash "$inline_setup_rendered" || inline_setup_status=1
- if [ -f "$HOME/.bash_profile" ]; then
- write_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered" || inline_setup_status=1
- elif [ -f "$HOME/.bash_login" ]; then
- write_path_block "$HOME/.bash_login" bash "$inline_setup_rendered" || inline_setup_status=1
- fi
- [ "$inline_setup_status" -eq 0 ] || return 1
- ;;
- *) return 1 ;;
- esac
+ inline_setup_list=$(shell_path_files "$inline_setup_shell") || return 1
+ inline_setup_status=0
+ while IFS= read -r inline_setup_file; do
+ [ -n "$inline_setup_file" ] || continue
+ if ! seed_bash_login_file "$inline_setup_shell" "$inline_setup_file"; then
+ inline_setup_status=1
+ continue
+ fi
+ write_path_block "$inline_setup_file" "$inline_setup_shell" "$inline_setup_rendered" ||
+ inline_setup_status=1
+ done <<EOF
+$inline_setup_list
+EOF
+ [ "$inline_setup_status" -eq 0 ] || return 1
return 0
}
@@ -446,20 +506,39 @@ delegated_file_current() {
# shell names the current bin dir before trusting the delegation.
delegated_setup_verified() {
delegated_rendered=$(render_bin_dir "$resolved_bin_dir")
- case $requested_shell in
- zsh) delegated_file_current "$HOME/.zshrc" "$(path_block_line zsh "$delegated_rendered")" ;;
- fish) delegated_file_current "$HOME/.config/fish/config.fish" "$(path_block_line fish "$delegated_rendered")" ;;
- bash)
- delegated_line=$(path_block_line bash "$delegated_rendered")
- delegated_file_current "$HOME/.bashrc" "$delegated_line" || return 1
- if [ -f "$HOME/.bash_profile" ]; then
- delegated_file_current "$HOME/.bash_profile" "$delegated_line"
- elif [ -f "$HOME/.bash_login" ]; then
- delegated_file_current "$HOME/.bash_login" "$delegated_line"
- fi
- ;;
- *) return 1 ;;
- esac
+ delegated_line=$(path_block_line "$requested_shell" "$delegated_rendered") || return 1
+ delegated_list=$(shell_path_files "$requested_shell") || return 1
+ delegated_status=0
+ while IFS= read -r delegated_file; do
+ [ -n "$delegated_file" ] || continue
+ delegated_file_current "$delegated_file" "$delegated_line" || delegated_status=1
+ done <<EOF
+$delegated_list
+EOF
+ [ "$delegated_status" -eq 0 ]
+}
+
+# Both setup paths disclose the same fact: which startup files now carry the
+# managed PATH block. Whether the CLI or the inline fallback wrote them is an
+# implementation detail that stays on the debug channel.
+report_configured_shell() {
+ report_configured_files=
+ report_configured_list=$(shell_path_files "$requested_shell") || report_configured_list=
+ while IFS= read -r report_configured_file; do
+ [ -n "$report_configured_file" ] || continue
+ if [ -z "$report_configured_files" ]; then
+ report_configured_files=$(tildify "$report_configured_file")
+ else
+ report_configured_files="$report_configured_files and $(tildify "$report_configured_file")"
+ fi
+ done <<EOF
+$report_configured_list
+EOF
+ if [ -n "$report_configured_files" ]; then
+ info "Configured $requested_shell shell setup in $report_configured_files."
+ else
+ info "Configured $requested_shell shell setup."
+ fi
}
setup_requested_shell() {
@@ -469,17 +548,28 @@ setup_requested_shell() {
fi
if "$exe" install --help 2>&1 | grep -q -- '--shell'; then
debug "delegating shell setup to $exe install --shell $requested_shell"
- if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$resolved_bin_dir" "$exe" install --shell "$requested_shell" &&
- delegated_setup_verified; then
- shell_configured=cli
- info "Configured $requested_shell shell setup ($shell_configured)."
+ # The delegated CLI prints its own branded report for a command the
+ # user never ran. Capture both of its streams so the installer keeps
+ # sole ownership of the presentation, and replay them under
+ # COMPOSIO_DEBUG so genuine failures stay diagnosable.
+ setup_delegated_log=$tmpdir/shell-setup-delegated.log
+ setup_delegated_status=0
+ COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$resolved_bin_dir" \
+ "$exe" install --shell "$requested_shell" >"$setup_delegated_log" 2>&1 ||
+ setup_delegated_status=$?
+ debug_captured_output \
+ "delegated shell setup exited $setup_delegated_status; captured output:" \
+ "$setup_delegated_log"
+ if [ "$setup_delegated_status" -eq 0 ] && delegated_setup_verified; then
+ debug "shell setup source: cli"
+ report_configured_shell
return 0
fi
fi
debug "falling back to inline $requested_shell shell setup"
if inline_shell_setup "$requested_shell" "$resolved_bin_dir"; then
- shell_configured=fallback
- info "Configured $requested_shell shell setup ($shell_configured)."
+ debug "shell setup source: fallback"
+ report_configured_shell
return 0
fi
return 1
@@ -555,6 +645,11 @@ print_setup_failure_ending() {
printf '\nComposio agent login complete.\n'
fi
warn "Automatic PATH setup for $requested_shell failed. The Composio CLI is installed and unaffected."
+ # The delegated CLI's own output is captured, so point at the channel that
+ # replays it instead of leaving the failure undiagnosable.
+ if ! is_true "${COMPOSIO_DEBUG:-}"; then
+ warn 'Re-run with COMPOSIO_DEBUG=1 for details.'
+ fi
if [ "$install_agent" = 1 ]; then
printf '\nRun composio from its installed location:\n\n %s --help\n' "$(shell_quote "$exe")" >&2
else
diff --git a/test/install-sh-release-resolution.test.sh b/test/install-sh-release-resolution.test.sh
index e4a0a223b..6fc1a938f 100755
--- a/test/install-sh-release-resolution.test.sh
+++ b/test/install-sh-release-resolution.test.sh
@@ -54,6 +54,34 @@ wait_for_file() {
fail "$label"
}
+# The single confirmation both setup paths print: it names the startup files
+# that now carry the managed block and never leaks internal vocabulary.
+configured_line() {
+ case $1 in
+ zsh) printf 'Configured zsh shell setup in ~/.zshrc.\n' ;;
+ bash) printf 'Configured bash shell setup in ~/.bashrc and ~/.bash_profile.\n' ;;
+ fish) printf 'Configured fish shell setup in ~/.config/fish/config.fish.\n' ;;
+ *) fail "configured_line: unknown shell $1" ;;
+ esac
+}
+
+# macOS Terminal.app starts bash as a login shell, which reads only the first
+# existing of ~/.bash_profile, ~/.bash_login, ~/.profile and never ~/.bashrc.
+# Probe a real login bash over the sandboxed HOME to prove the PATH entry
+# actually lands somewhere it reads.
+assert_login_bash_path() {
+ local home=$1
+ local bin=$2
+ local label=$3
+ local login_path
+ login_path=$(env -i HOME="$home" PATH=/usr/bin:/bin bash -lc 'printf %s "$PATH"') ||
+ fail "$label (login bash probe failed)"
+ case ":$login_path:" in
+ *":$bin:"*) ;;
+ *) fail "$label (login bash PATH lacks $bin: $login_path)" ;;
+ esac
+}
+
for script in "$repo_root/install.sh" "$repo_root"/install/*.sh; do
[[ $(tail -n 1 "$script") == 'main "$@"' ]] || fail "$script must end with main \"\$@\""
[[ $(grep -c '^main "\$@"$' "$script") -eq 1 ]] || fail "$script must contain one main entry point"
@@ -317,11 +345,15 @@ install)
write_block "$HOME/.config/fish/config.fish" "set --export PATH \"$COMPOSIO_BIN_DIR\" \$PATH"
;;
bash)
+ # Login bash never reads .bashrc, so the CLI also configures a
+ # login-mode file, creating ~/.bash_profile when no override exists.
+ # (The real CLI additionally seeds a ~/.profile passthrough into a file
+ # it creates; that belongs to the CLI and is covered by its unit tests.)
write_block "$HOME/.bashrc" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
- if [ -f "$HOME/.bash_profile" ]; then
- write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
- elif [ -f "$HOME/.bash_login" ]; then
+ if [ ! -f "$HOME/.bash_profile" ] && [ -f "$HOME/.bash_login" ]; then
write_block "$HOME/.bash_login" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
+ else
+ write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
fi
;;
esac
@@ -444,12 +476,19 @@ EOF
[[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"
assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"
grep -Fq "|installer|$bin_dir|install --shell bash" "$composio_log" || fail "$interpreter_name default auto delegation"
- assert_contains "$output" 'Configured bash shell setup (cli).' "$interpreter_name default auto confirmation"
+ assert_contains "$output" "$(configured_line bash)" "$interpreter_name default auto confirmation"
+ assert_not_contains "$output" '(cli)' "$interpreter_name confirmation must not leak internal labels"
+ assert_not_contains "$output" '(fallback)' "$interpreter_name confirmation must not leak internal labels"
# Inherited-PATH contract: the installer prepends the bin dir to its own PATH
# for delegated CLI calls, but the ending must reflect only the PATH the
# invoking terminal inherited, which does not contain the bin dir here.
assert_tail "$output" "$case_b_tail" "$interpreter_name default auto Case B tail"
grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bashrc" || fail "$interpreter_name delegated default flow rc written by the CLI"
+ # A login bash reads none of ~/.bashrc, so the delegated path must reach a
+ # login-mode startup file as well.
+ grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bash_profile" ||
+ fail "$interpreter_name delegated default flow login file written by the CLI"
+ assert_login_bash_path "$home" "$bin_dir" "$interpreter_name delegated default flow login shell"
assert_not_contains "$output" 'Updated ~/.bashrc' "$interpreter_name delegated default flow must not rewrite rc files inline"
[[ $(wc -l <"$composio_log") -eq 3 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"
@@ -537,7 +576,7 @@ EOF
reset_case
CASE_HELP=0
help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)
- assert_contains "$help_suppressed" 'Configured bash shell setup (cli).' "$interpreter_name help suppression keeps setup status"
+ assert_contains "$help_suppressed" "$(configured_line bash)" "$interpreter_name help suppression keeps setup status"
assert_not_contains "$help_suppressed" 'composio login' "$interpreter_name help suppression removes the final block"
assert_not_contains "$help_suppressed" 'Open a new terminal' "$interpreter_name help suppression removes the final block"
@@ -627,7 +666,7 @@ EOF
variant_output=$(run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins 2>&1)
grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||
fail "$interpreter_name $shell_name variant delegation"
- assert_contains "$variant_output" "Configured $shell_name shell setup (cli)." "$interpreter_name $shell_name variant confirmation"
+ assert_contains "$variant_output" "$(configured_line "$shell_name")" "$interpreter_name $shell_name variant confirmation"
assert_not_contains "$variant_output" 'Required next step' "$interpreter_name $shell_name variant must not print setup guidance"
assert_not_contains "$variant_output" 'Optional shell setup' "$interpreter_name $shell_name variant must not print setup guidance"
done
@@ -638,7 +677,7 @@ EOF
direct_bin="$case_root/direct-shell-bin"
direct_output=$(run_installer "$direct_home" "$case_root/direct-shell-install" "$direct_bin" "$stable_tag" 2>&1)
grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL delegation"
- assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
+ assert_contains "$direct_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
assert_not_contains "$direct_output" 'Required next step' "$interpreter_name COMPOSIO_INSTALL_SHELL must not print setup guidance"
assert_tail "$direct_output" "$case_b_tail" "$interpreter_name COMPOSIO_INSTALL_SHELL Case B tail"
grep -Fq "export PATH=\"$direct_bin:\$PATH\"" "$direct_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL CLI-written block"
@@ -650,7 +689,7 @@ EOF
direct_fallback_home="$case_root/direct-fallback-home"
direct_fallback_output=$(run_installer "$direct_fallback_home" "$case_root/direct-fallback-install" "$case_root/direct-fallback-bin" "$stable_tag" 2>&1)
grep -Fqx '# Composio CLI' "$direct_fallback_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL unsupported CLI fallback"
- assert_contains "$direct_fallback_output" 'Configured zsh shell setup (fallback).' "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation"
+ assert_contains "$direct_fallback_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation"
reset_case
CASE_INSTALL_SHELL=fish
@@ -726,7 +765,7 @@ EOF
auto_output=$(run_installer "$auto_home" "$auto_install" "$auto_bin" "$stable_tag" 2>&1)
grep -Fq "|installer|$auto_bin|install --shell $auto_shell" "$composio_log" ||
fail "$interpreter_name auto $auto_shell delegation"
- assert_contains "$auto_output" "Configured $auto_shell shell setup (cli)." "$interpreter_name auto $auto_shell confirmation"
+ assert_contains "$auto_output" "$(configured_line "$auto_shell")" "$interpreter_name auto $auto_shell confirmation"
assert_tail "$auto_output" "$case_b_tail" "$interpreter_name auto $auto_shell Case B tail"
done
@@ -818,8 +857,9 @@ EOF
# Pinned old CLI: supports --shell but ignores the invocation-origin hint,
# prints its own boxed restart hint, and exits 0 without reconciling. A
# relative COMPOSIO_BIN_DIR must never reach setup raw; the installer must
- # detect the unreconciled startup file and repair it inline; its plain final
- # block prints after the old hint and supersedes it.
+ # detect the unreconciled startup file and repair it inline. The delegated
+ # command's own presentation never reaches the user: the installer owns its
+ # output and its plain final block is the only ending.
reset_case
CASE_INSTALL_HINT=1
CASE_INSTALL_RECONCILE=0
@@ -832,10 +872,73 @@ EOF
fail "$interpreter_name old-CLI setup must receive the resolved absolute bin dir"
grep -Fq "export PATH=\"$oldcli_work/rel-bin:\$PATH\"" "$oldcli_home/.bashrc" ||
fail "$interpreter_name old-CLI delegation must be reconciled inline with the absolute bin dir"
- assert_contains "$oldcli_output" 'Configured bash shell setup (fallback).' "$interpreter_name old-CLI reconciliation disclosure"
- assert_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name old-CLI restart hint passes through"
+ assert_contains "$oldcli_output" "$(configured_line bash)" "$interpreter_name old-CLI reconciliation disclosure"
+ assert_not_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name delegated CLI output must not leak"
assert_tail "$oldcli_output" "$case_b_tail" "$interpreter_name old-CLI hint superseded by the installer tail"
+ # The suppressed delegated output stays available for troubleshooting.
+ reset_case
+ CASE_INSTALL_HINT=1
+ CASE_DEBUG=1
+ delegated_debug_output=$(run_installer "$case_root/delegated-debug-home" "$case_root/delegated-debug-install" "$case_root/delegated-debug-bin" "$stable_tag" 2>&1)
+ assert_contains "$delegated_debug_output" 'delegated shell setup exited 0' "$interpreter_name debug reports the delegated exit status"
+ assert_contains "$delegated_debug_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name debug replays the captured delegated output"
+ assert_contains "$delegated_debug_output" '+ shell setup source: cli' "$interpreter_name debug keeps the setup-source distinction"
+
+ # --- Login-shell reachability for bash (macOS Terminal.app) ---
+
+ # Inline path, virgin home: ~/.bashrc alone is unreachable from a login bash,
+ # so the installer must also create a login-mode startup file.
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ CASE_SHELL_VALUE=/bin/bash
+ bash_login_home="$case_root/bash-login-home"
+ bash_login_bin="$case_root/bash-login-bin"
+ bash_login_output=$(run_installer "$bash_login_home" "$case_root/bash-login-install" "$bash_login_bin" "$stable_tag" 2>&1)
+ grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bashrc" ||
+ fail "$interpreter_name inline bash setup must configure .bashrc"
+ grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bash_profile" ||
+ fail "$interpreter_name inline bash setup must configure a login-mode startup file"
+ assert_login_bash_path "$bash_login_home" "$bash_login_bin" "$interpreter_name inline bash login shell"
+ assert_contains "$bash_login_output" "$(configured_line bash)" "$interpreter_name inline bash names both startup files"
+ [[ ! -e "$bash_login_home/.profile" ]] || fail "$interpreter_name inline bash setup must not create ~/.profile"
+
+ # A created ~/.bash_profile shadows an existing ~/.profile, so it must keep
+ # sourcing it — and must never rewrite ~/.profile itself.
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ CASE_SHELL_VALUE=/bin/bash
+ bash_profile_home="$case_root/bash-profile-home"
+ bash_profile_bin="$case_root/bash-profile-bin"
+ mkdir -p "$bash_profile_home"
+ printf '%s\n' 'export DISTRO_PROFILE=1' >"$bash_profile_home/.profile"
+ run_installer "$bash_profile_home" "$case_root/bash-profile-install" "$bash_profile_bin" "$stable_tag" >/dev/null 2>&1
+ grep -Fq '. "$HOME/.profile"' "$bash_profile_home/.bash_profile" ||
+ fail "$interpreter_name a created .bash_profile must keep sourcing ~/.profile"
+ [[ $(<"$bash_profile_home/.profile") == 'export DISTRO_PROFILE=1' ]] ||
+ fail "$interpreter_name ~/.profile must not be modified"
+ assert_login_bash_path "$bash_profile_home" "$bash_profile_bin" "$interpreter_name shadowed profile login shell"
+ shadowed_profile_value=$(env -i HOME="$bash_profile_home" PATH=/usr/bin:/bin bash -lc 'printf %s "${DISTRO_PROFILE:-}"')
+ [[ $shadowed_profile_value == 1 ]] ||
+ fail "$interpreter_name a created .bash_profile must not shadow ~/.profile content"
+
+ # An existing ~/.bash_login is the login file bash reads, so it is reused and
+ # no ~/.bash_profile is invented in front of it.
+ reset_case
+ CASE_SHELL_CAPABILITY=unsupported
+ CASE_SHELL_VALUE=/bin/bash
+ bash_login_only_home="$case_root/bash-login-only-home"
+ bash_login_only_bin="$case_root/bash-login-only-bin"
+ mkdir -p "$bash_login_only_home"
+ printf '%s\n' 'export LOGIN_OVERRIDE=1' >"$bash_login_only_home/.bash_login"
+ bash_login_only_output=$(run_installer "$bash_login_only_home" "$case_root/bash-login-only-install" "$bash_login_only_bin" "$stable_tag" 2>&1)
+ grep -Fq "export PATH=\"$bash_login_only_bin:\$PATH\"" "$bash_login_only_home/.bash_login" ||
+ fail "$interpreter_name existing .bash_login must receive the managed block"
+ [[ ! -e "$bash_login_only_home/.bash_profile" ]] ||
+ fail "$interpreter_name an existing .bash_login must not be shadowed by a new .bash_profile"
+ assert_contains "$bash_login_only_output" 'Configured bash shell setup in ~/.bashrc and ~/.bash_login.' "$interpreter_name .bash_login disclosure"
+ assert_login_bash_path "$bash_login_only_home" "$bash_login_only_bin" "$interpreter_name .bash_login login shell"
+
# --- Setup write failures stay non-fatal (KD3/KD4) ---
# Delegated path: CLI --shell fails, inline fallback also fails.
@@ -849,6 +952,7 @@ EOF
fail "$interpreter_name delegated setup failure must keep the install successful"
[[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary"
assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning"
+ assert_contains "$wf_delegated_output" 'COMPOSIO_DEBUG=1' "$interpreter_name delegated setup failure points at the captured output"
assert_tail "$wf_delegated_output" $'To get started, run:\n\n '"$wf_delegated_install/composio login" "$interpreter_name delegated setup failure recovery tail"
# Inline path: helper failure inside a conditional must propagate explicitly.
@@ -970,7 +1074,7 @@ export PATH=\"$malformed_bin:\$PATH\"" ]] || fail "$interpreter_name malformed b
printf '%s\n' 'alias stale-guard=1' '' '# Composio CLI' 'export PATH="/stale/old-bin:$PATH"' >"$stale_home/.zshrc"
stale_output=$(run_installer "$stale_home" "$case_root/stale-delegated-install" "$stale_bin" "$stable_tag" 2>&1)
grep -Fq "|installer|$stale_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name stale delegation still delegates first"
- assert_contains "$stale_output" 'Configured zsh shell setup (fallback).' "$interpreter_name stale delegation reconciles inline"
+ assert_contains "$stale_output" "$(configured_line zsh)" "$interpreter_name stale delegation reconciles inline"
[[ $(grep -Fc '# Composio CLI' "$stale_home/.zshrc") -eq 1 ]] || fail "$interpreter_name stale reconcile keeps one marker block"
grep -Fq "export PATH=\"$stale_bin:\$PATH\"" "$stale_home/.zshrc" || fail "$interpreter_name stale reconcile names the current bin dir"
if grep -Fq '/stale/old-bin' "$stale_home/.zshrc"; then
diff --git a/ts/e2e-tests/cli/install/e2e.test.ts b/ts/e2e-tests/cli/install/e2e.test.ts
index 23f078b1b..de5289af1 100644
--- a/ts/e2e-tests/cli/install/e2e.test.ts
+++ b/ts/e2e-tests/cli/install/e2e.test.ts
@@ -103,14 +103,22 @@ if (config.mode === 'local' && config.shell === 'bash') {
async () => {
// Docker execs typically leave $SHELL unset, so every default-flow
// invocation exports it explicitly for the auto-detection contract.
+ // A login bash never reads ~/.bashrc, so a virgin home must also come
+ // out with a login-mode startup file; `bash -lc` (no -i) proves it.
const result = await run(`
set -eu
+${shellHelpers}
test ! -d "$HOME/.local/bin"
+test ! -e "$HOME/.bash_profile"
curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash sh
test -x "$HOME/.composio/composio"
test -L "$HOME/.local/bin/composio"
test "$(readlink -f "$HOME/.local/bin/composio")" = "$HOME/.composio/composio"
test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
+test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1
+grep -Fq '. "$HOME/.profile"' "$HOME/.bash_profile"
+assert_no_marker_block "$HOME/.profile"
+test "$(bash -lc 'command -v composio')" = "$HOME/.local/bin/composio"
test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
test "$(bash -ilc 'composio --version')" = 98.0.0
`);
diff --git a/ts/packages/cli/CHANGELOG.md b/ts/packages/cli/CHANGELOG.md
index 3c67657a0..1615b94f9 100644
--- a/ts/packages/cli/CHANGELOG.md
+++ b/ts/packages/cli/CHANGELOG.md
@@ -5,7 +5,7 @@
### Minor Changes
- The installer (`curl -fsSL https://composio.dev/install | sh`) now configures your shell automatically: `COMPOSIO_INSTALL_SHELL` defaults to `auto`, which infers the login shell from `$SHELL` (zsh, bash, or fish) and always runs idempotent PATH setup for it; `COMPOSIO_INSTALL_SHELL=none` keeps the old install-only behavior for CI, Docker, and dotfile managers. Startup-file setup failures no longer fail the install — the installer keeps the binary, warns, and prints a runnable absolute-path command. `composio install` now reconciles an existing managed PATH block whose bin directory changed (one block per physical file, symlink-aware) and suppresses its boxed restart hint when invoked by the installer, which owns the final message.
-- `composio install` gains a `--shell <zsh|bash|fish>` flag that overrides `$SHELL` detection, in preparation for the mise-style installer rewrite. The bin-dir PATH target now resolves through `COMPOSIO_BIN_DIR`, an existing `~/.local/bin/composio`, or the real binary's own directory, in that order, instead of hardcoding `~/.composio`; rc blocks write only a PATH line (the `export COMPOSIO_INSTALL_DIR=...` line is gone, since that variable identifies the install bundle, not the PATH entry point). Bash now also writes the PATH line to `~/.bash_profile` or `~/.bash_login` when either already exists, so `bash -ilc` picks it up. The restart hint bug is fixed: bash now prints `source ~/.bashrc` instead of the literal string `exec $SHELL`.
+- `composio install` gains a `--shell <zsh|bash|fish>` flag that overrides `$SHELL` detection, in preparation for the mise-style installer rewrite. The bin-dir PATH target now resolves through `COMPOSIO_BIN_DIR`, an existing `~/.local/bin/composio`, or the real binary's own directory, in that order, instead of hardcoding `~/.composio`; rc blocks write only a PATH line (the `export COMPOSIO_INSTALL_DIR=...` line is gone, since that variable identifies the install bundle, not the PATH entry point). Bash now always writes the PATH line to a login-mode startup file as well as `~/.bashrc`, so `bash -ilc` (and macOS Terminal.app, which starts a login shell) picks it up: the first existing of `~/.bash_profile` or `~/.bash_login`, or a newly created `~/.bash_profile` when neither exists. A `~/.bash_profile` created this way shadows `~/.profile`, so it is seeded to source it first; `~/.profile` itself is never modified. The restart hint bug is fixed: bash now prints `source ~/.bashrc` instead of the literal string `exec $SHELL`.
### Patch Changes
diff --git a/ts/packages/cli/src/commands/install.cmd.ts b/ts/packages/cli/src/commands/install.cmd.ts
index 079e90724..0f649acd0 100644
--- a/ts/packages/cli/src/commands/install.cmd.ts
+++ b/ts/packages/cli/src/commands/install.cmd.ts
@@ -123,37 +123,64 @@ const pathBlockForShell = (shell: Shell, binDir: string, homedir: string): strin
: [MARKER, `export PATH="${rendered}:$PATH"`].join('\n');
};
-/** Bash startup-file candidates that only bash's login mode reads, in read order. */
-const bashLoginOverrideCandidates = (path: Path.Path, homedir: string): string[] => [
- path.join(homedir, '.bash_profile'),
- path.join(homedir, '.bash_login'),
-];
+/**
+ * The bash startup file a login shell reads the managed PATH block from, and
+ * whether creating it means taking over from an existing `~/.profile`.
+ */
+interface BashLoginFile {
+ readonly file: string;
+ readonly seedsProfilePassthrough: boolean;
+}
/**
- * First existing bash login-override file, if any. `bash -ilc` reads only the
- * first of `.bash_profile`, `.bash_login`, `.profile` that exists — so an
- * existing override shadows `.profile` and common `.profile` files source
- * `.bashrc`, unless the PATH line also lands in the override. `.profile` is
- * deliberately not a candidate below: when neither override exists, bash reads
- * `.profile` itself, and common `.profile` files already source `.bashrc`, so
- * nothing needs to be written to it.
+ * Preamble for a `~/.bash_profile` this command creates. A login bash reads
+ * `/etc/profile` and then only the first existing of `.bash_profile`,
+ * `.bash_login`, `.profile`, so a newly created `.bash_profile` shadows a
+ * `.profile` the shell read until now. Sourcing it back keeps that content —
+ * including the Debian-style `.profile` that itself sources `.bashrc` — while
+ * leaving `.profile` (shared with every other POSIX shell) untouched.
+ */
+const BASH_PROFILE_PASSTHROUGH = [
+ '# Created by the Composio CLI installer.',
+ '# Bash reads this file instead of ~/.profile in login shells.',
+ 'if [ -f "$HOME/.profile" ]; then',
+ ' . "$HOME/.profile"',
+ 'fi',
+].join('\n');
+
+/**
+ * Resolve the bash startup file that login-mode bash reads.
+ *
+ * Login bash never reads `.bashrc` — macOS Terminal.app starts exactly such a
+ * shell — so the PATH block has to reach a login-mode file too. An existing
+ * override (`.bash_profile`, then `.bash_login`) is reused; when neither
+ * exists, `.bash_profile` is created rather than writing the shared
+ * `.profile`, which a `.bash_profile` would shadow anyway.
*/
-const resolveBashLoginOverride = (
- candidates: readonly string[],
+const resolveBashLoginFile = (
+ path: Path.Path,
+ homedir: string,
fs: FileSystem.FileSystem
-): Effect.Effect<string | undefined, PlatformError> =>
+): Effect.Effect<BashLoginFile, PlatformError> =>
Effect.gen(function* () {
- for (const candidate of candidates) {
- if (yield* fs.exists(candidate)) return candidate;
+ const bashProfile = path.join(homedir, '.bash_profile');
+ if (yield* fs.exists(bashProfile)) {
+ return { file: bashProfile, seedsProfilePassthrough: false };
+ }
+ const bashLogin = path.join(homedir, '.bash_login');
+ if (yield* fs.exists(bashLogin)) {
+ return { file: bashLogin, seedsProfilePassthrough: false };
}
- return undefined;
+ const profileExists = yield* fs.exists(path.join(homedir, '.profile'));
+ return { file: bashProfile, seedsProfilePassthrough: profileExists };
});
+/** Bash always configures both files: `.bashrc` for interactive shells, the login file for login shells. */
const pathFilesForShell = (
path: Path.Path,
shell: Shell,
homedir: string,
- bashLoginOverride: string | undefined
+ bashLoginFile: string | undefined
): string[] => {
switch (shell) {
case 'zsh':
@@ -162,7 +189,7 @@ const pathFilesForShell = (
return [path.join(homedir, '.config', 'fish', 'config.fish')];
case 'bash': {
const bashrc = path.join(homedir, '.bashrc');
- return bashLoginOverride ? [bashrc, bashLoginOverride] : [bashrc];
+ return bashLoginFile ? [bashrc, bashLoginFile] : [bashrc];
}
}
};
@@ -579,10 +606,9 @@ export const installShellIntegration = (params: {
completionScript = lines.length > 0 ? Arr.join(lines, '\n') : undefined;
}
- const bashLoginOverride =
- shell === 'bash'
- ? yield* resolveBashLoginOverride(bashLoginOverrideCandidates(path, os.homedir), fs)
- : undefined;
+ const bashLoginFile =
+ shell === 'bash' ? yield* resolveBashLoginFile(path, os.homedir, fs) : undefined;
+ const bashLoginOverride = bashLoginFile?.file;
const pathFiles = pathFilesForShell(path, shell, os.homedir, bashLoginOverride);
const config = buildShellConfig(path, shell, pathFiles, binDir, completionScript, os.homedir);
@@ -631,6 +657,14 @@ export const installShellIntegration = (params: {
skipPathWriteForReachability,
});
const { replacementsByTarget, loginOverrideWritten } = writePlan;
+ // A `.bash_profile` created here takes over from an existing `~/.profile`,
+ // so it leads with the passthrough that keeps sourcing it.
+ if (
+ bashLoginFile?.seedsProfilePassthrough === true &&
+ writePlan.appendPathFiles.includes(bashLoginFile.file)
+ ) {
+ pushBlock(bashLoginFile.file, BASH_PROFILE_PASSTHROUGH);
+ }
for (const filePath of writePlan.appendPathFiles) {
pushBlock(filePath, config.pathBlock);
}
diff --git a/ts/packages/cli/test/src/commands/install.cmd.test.ts b/ts/packages/cli/test/src/commands/install.cmd.test.ts
index f4ba6ea9b..a770158cd 100644
--- a/ts/packages/cli/test/src/commands/install.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/install.cmd.test.ts
@@ -148,17 +148,55 @@ describe('CLI: composio install', () => {
describe('[When] bash has neither .bash_profile nor .bash_login', () => {
layer(InstallTestLive())(it => {
- it.scoped('[Then] only .bashrc is created', () =>
+ // A login bash (macOS Terminal.app's default) never reads .bashrc, so
+ // the PATH block only reaches it through a created .bash_profile.
+ it.scoped('[Then] .bash_profile is created alongside .bashrc', () =>
Effect.gen(function* () {
const os = yield* NodeOs;
vi.stubEnv('SHELL', '/bin/bash');
+ const expectedBinDir = expectedRuntimeBinDir();
yield* install();
const fs = yield* FileSystem.FileSystem;
+ const bashProfilePath = path.join(os.homedir, '.bash_profile');
expect(yield* fs.exists(path.join(os.homedir, '.bashrc'))).toBe(true);
- expect(yield* fs.exists(path.join(os.homedir, '.bash_profile'))).toBe(false);
+ expect(yield* fs.exists(bashProfilePath)).toBe(true);
expect(yield* fs.exists(path.join(os.homedir, '.bash_login'))).toBe(false);
+
+ const bashProfileContents = yield* fs.readFileString(bashProfilePath);
+ expect(bashProfileContents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
+ // No ~/.profile existed, so nothing had to be sourced back.
+ expect(bashProfileContents).not.toContain('.profile');
+ })
+ );
+ });
+ });
+
+ describe('[When] bash has no login file but an existing ~/.profile', () => {
+ layer(InstallTestLive())(it => {
+ it.scoped('[Then] the created .bash_profile sources ~/.profile, which stays untouched', () =>
+ Effect.gen(function* () {
+ const os = yield* NodeOs;
+ const fs = yield* FileSystem.FileSystem;
+ vi.stubEnv('SHELL', '/bin/bash');
+ const expectedBinDir = expectedRuntimeBinDir();
+
+ const profilePath = path.join(os.homedir, '.profile');
+ yield* fs.writeFileString(profilePath, '# distro profile\n');
+
+ yield* install();
+
+ const bashProfileContents = yield* fs.readFileString(
+ path.join(os.homedir, '.bash_profile')
+ );
+ expect(bashProfileContents).toContain('. "$HOME/.profile"');
+ expect(bashProfileContents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
+ // The passthrough must precede the managed block it leads into.
+ expect(bashProfileContents.indexOf('. "$HOME/.profile"')).toBeLessThan(
+ bashProfileContents.indexOf('# Composio CLI')
+ );
+ expect(yield* fs.readFileString(profilePath)).toBe('# distro profile\n');
})
);
});