@devries-cameron20 / composio Mirror · read-only / commits / aaf2d250c
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 17:15 UTC

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

A login bash reads /etc/profile and then only the first existing of ~/.bash_profile, ~/.bash_login, ~/.profile; it never reads ~/.bashrc. macOS Terminal.app starts exactly such a shell, so a terminal opened after installation could not resolve composio even though the installer reported success. Always configure a login-mode startup file alongside ~/.bashrc: reuse an existing ~/.bash_profile or ~/.bash_login, otherwise create ~/.bash_profile seeded to keep sourcing ~/.profile, which it shadows. ~/.profile itself is never rewritten. Also refine the shell setup reporting: - capture the delegated `composio install --shell` output so the installer keeps sole ownership of its presentation, replaying it under COMPOSIO_DEBUG so failures stay diagnosable - drop the internal (cli)/(fallback) labels from user-facing output - name the configured startup files from both the delegated and inline paths, so piped installs disclose which files changed

jkomyno committed Aug 3, 2026 at 19:24 UTC aaf2d250cfb922f5bddac63821eb8a5c3db9425e
8 files changed +358 -79
INSTALL.md
+1 -1
@@ -6,7 +6,7 @@ Install the CLI bundle in `~/.composio` and its entry point in `~/.local/bin`:
6 curl -fsSL https://composio.dev/install | sh
7 ```
8
9 -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`.
9 +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`.
10
11 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.
12
docs/content/docs/cli.mdx
+2 -2
@@ -16,7 +16,7 @@ Install the CLI with one command:
16 curl -fsSL https://composio.dev/install | sh
17 ```
18
19 -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).
19 +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).
20
21 Open a new terminal, then log in:
22
@@ -80,7 +80,7 @@ This configures `~/.zshrc` and delegates setup to `composio install --shell zsh`
80 curl -fsSL https://composio.dev/install | COMPOSIO_INSTALL_SHELL=bash sh
81 ```
82
83 -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`.
83 +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.
84 </Tab>
85 <Tab value="fish">
86 ```bash
install.sh
+130 -35
@@ -29,6 +29,19 @@ debug() {
29 fi
30 }
31
32 +# Replays a captured subprocess log on the debug channel. The installer owns
33 +# its own presentation, so delegated output is suppressed by default and stays
34 +# available for troubleshooting through COMPOSIO_DEBUG.
35 +debug_captured_output() {
36 + debug_captured_label=$1
37 + debug_captured_file=$2
38 + if ! is_true "${COMPOSIO_DEBUG:-}" || [ ! -s "$debug_captured_file" ]; then
39 + return 0
40 + fi
41 + debug "$debug_captured_label"
42 + sed 's/^/+ /' "$debug_captured_file" >&2 || :
43 +}
44 +
45 tildify() {
46 case $1 in
47 "$HOME"/*) printf '%s/%s\n' '~' "${1#"$HOME"/}" ;;
@@ -410,6 +423,54 @@ write_path_block() {
423 return 0
424 }
425
426 +# Names the bash startup file a login shell reads the managed block from.
427 +# A login bash reads /etc/profile and then only the first existing of
428 +# ~/.bash_profile, ~/.bash_login, ~/.profile; it never reads ~/.bashrc, and
429 +# macOS Terminal.app starts exactly such a shell. An override that already
430 +# exists is reused; otherwise ~/.bash_profile is the file to create. ~/.profile
431 +# is never a target: every POSIX shell shares it.
432 +bash_login_path_file() {
433 + if [ ! -f "$HOME/.bash_profile" ] && [ -f "$HOME/.bash_login" ]; then
434 + printf '%s\n' "$HOME/.bash_login"
435 + else
436 + printf '%s\n' "$HOME/.bash_profile"
437 + fi
438 +}
439 +
440 +# Single source of truth for the startup files the managed PATH block lands in,
441 +# in write order. Both setup paths and the confirmation message read it, so the
442 +# files the installer configures are exactly the files it verifies and names.
443 +shell_path_files() {
444 + case $1 in
445 + zsh) printf '%s\n' "$HOME/.zshrc" ;;
446 + fish) printf '%s\n' "$HOME/.config/fish/config.fish" ;;
447 + bash) printf '%s\n' "$HOME/.bashrc" "$(bash_login_path_file)" ;;
448 + *) return 1 ;;
449 + esac
450 +}
451 +
452 +# A ~/.bash_profile the installer creates shadows an existing ~/.profile, which
453 +# login bash read while no override existed. Seed the new file so it keeps
454 +# sourcing it; ~/.profile itself is left untouched.
455 +seed_bash_login_file() {
456 + seed_login_shell=$1
457 + seed_login_file=$2
458 + if [ "$seed_login_shell" != bash ] || [ "$seed_login_file" != "$HOME/.bash_profile" ]; then
459 + return 0
460 + fi
461 + if [ -e "$seed_login_file" ] || [ ! -f "$HOME/.profile" ]; then
462 + return 0
463 + fi
464 + cat >"$seed_login_file" 2>/dev/null <<'SEED_BASH_LOGIN_FILE' || return 1
465 +# Created by the Composio CLI installer.
466 +# Bash reads this file instead of ~/.profile in login shells.
467 +if [ -f "$HOME/.profile" ]; then
468 + . "$HOME/.profile"
469 +fi
470 +SEED_BASH_LOGIN_FILE
471 + return 0
472 +}
473 +
474 inline_shell_setup() {
475 inline_setup_shell=$1
476 inline_setup_bin_dir=$2
@@ -417,21 +478,20 @@ inline_shell_setup() {
478 return 1
479 fi
480 inline_setup_rendered=$(render_bin_dir "$inline_setup_bin_dir")
420 - case $inline_setup_shell in
421 - zsh) write_path_block "$HOME/.zshrc" zsh "$inline_setup_rendered" || return 1 ;;
422 - fish) write_path_block "$HOME/.config/fish/config.fish" fish "$inline_setup_rendered" || return 1 ;;
423 - bash)
424 - inline_setup_status=0
425 - write_path_block "$HOME/.bashrc" bash "$inline_setup_rendered" || inline_setup_status=1
426 - if [ -f "$HOME/.bash_profile" ]; then
427 - write_path_block "$HOME/.bash_profile" bash "$inline_setup_rendered" || inline_setup_status=1
428 - elif [ -f "$HOME/.bash_login" ]; then
429 - write_path_block "$HOME/.bash_login" bash "$inline_setup_rendered" || inline_setup_status=1
430 - fi
431 - [ "$inline_setup_status" -eq 0 ] || return 1
432 - ;;
433 - *) return 1 ;;
434 - esac
481 + inline_setup_list=$(shell_path_files "$inline_setup_shell") || return 1
482 + inline_setup_status=0
483 + while IFS= read -r inline_setup_file; do
484 + [ -n "$inline_setup_file" ] || continue
485 + if ! seed_bash_login_file "$inline_setup_shell" "$inline_setup_file"; then
486 + inline_setup_status=1
487 + continue
488 + fi
489 + write_path_block "$inline_setup_file" "$inline_setup_shell" "$inline_setup_rendered" ||
490 + inline_setup_status=1
491 + done <<EOF
492 +$inline_setup_list
493 +EOF
494 + [ "$inline_setup_status" -eq 0 ] || return 1
495 return 0
496 }
497
@@ -446,20 +506,39 @@ delegated_file_current() {
506 # shell names the current bin dir before trusting the delegation.
507 delegated_setup_verified() {
508 delegated_rendered=$(render_bin_dir "$resolved_bin_dir")
449 - case $requested_shell in
450 - zsh) delegated_file_current "$HOME/.zshrc" "$(path_block_line zsh "$delegated_rendered")" ;;
451 - fish) delegated_file_current "$HOME/.config/fish/config.fish" "$(path_block_line fish "$delegated_rendered")" ;;
452 - bash)
453 - delegated_line=$(path_block_line bash "$delegated_rendered")
454 - delegated_file_current "$HOME/.bashrc" "$delegated_line" || return 1
455 - if [ -f "$HOME/.bash_profile" ]; then
456 - delegated_file_current "$HOME/.bash_profile" "$delegated_line"
457 - elif [ -f "$HOME/.bash_login" ]; then
458 - delegated_file_current "$HOME/.bash_login" "$delegated_line"
459 - fi
460 - ;;
461 - *) return 1 ;;
462 - esac
509 + delegated_line=$(path_block_line "$requested_shell" "$delegated_rendered") || return 1
510 + delegated_list=$(shell_path_files "$requested_shell") || return 1
511 + delegated_status=0
512 + while IFS= read -r delegated_file; do
513 + [ -n "$delegated_file" ] || continue
514 + delegated_file_current "$delegated_file" "$delegated_line" || delegated_status=1
515 + done <<EOF
516 +$delegated_list
517 +EOF
518 + [ "$delegated_status" -eq 0 ]
519 +}
520 +
521 +# Both setup paths disclose the same fact: which startup files now carry the
522 +# managed PATH block. Whether the CLI or the inline fallback wrote them is an
523 +# implementation detail that stays on the debug channel.
524 +report_configured_shell() {
525 + report_configured_files=
526 + report_configured_list=$(shell_path_files "$requested_shell") || report_configured_list=
527 + while IFS= read -r report_configured_file; do
528 + [ -n "$report_configured_file" ] || continue
529 + if [ -z "$report_configured_files" ]; then
530 + report_configured_files=$(tildify "$report_configured_file")
531 + else
532 + report_configured_files="$report_configured_files and $(tildify "$report_configured_file")"
533 + fi
534 + done <<EOF
535 +$report_configured_list
536 +EOF
537 + if [ -n "$report_configured_files" ]; then
538 + info "Configured $requested_shell shell setup in $report_configured_files."
539 + else
540 + info "Configured $requested_shell shell setup."
541 + fi
542 }
543
544 setup_requested_shell() {
@@ -469,17 +548,28 @@ setup_requested_shell() {
548 fi
549 if "$exe" install --help 2>&1 | grep -q -- '--shell'; then
550 debug "delegating shell setup to $exe install --shell $requested_shell"
472 - if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$resolved_bin_dir" "$exe" install --shell "$requested_shell" &&
473 - delegated_setup_verified; then
474 - shell_configured=cli
475 - info "Configured $requested_shell shell setup ($shell_configured)."
551 + # The delegated CLI prints its own branded report for a command the
552 + # user never ran. Capture both of its streams so the installer keeps
553 + # sole ownership of the presentation, and replay them under
554 + # COMPOSIO_DEBUG so genuine failures stay diagnosable.
555 + setup_delegated_log=$tmpdir/shell-setup-delegated.log
556 + setup_delegated_status=0
557 + COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$resolved_bin_dir" \
558 + "$exe" install --shell "$requested_shell" >"$setup_delegated_log" 2>&1 ||
559 + setup_delegated_status=$?
560 + debug_captured_output \
561 + "delegated shell setup exited $setup_delegated_status; captured output:" \
562 + "$setup_delegated_log"
563 + if [ "$setup_delegated_status" -eq 0 ] && delegated_setup_verified; then
564 + debug "shell setup source: cli"
565 + report_configured_shell
566 return 0
567 fi
568 fi
569 debug "falling back to inline $requested_shell shell setup"
570 if inline_shell_setup "$requested_shell" "$resolved_bin_dir"; then
481 - shell_configured=fallback
482 - info "Configured $requested_shell shell setup ($shell_configured)."
571 + debug "shell setup source: fallback"
572 + report_configured_shell
573 return 0
574 fi
575 return 1
@@ -555,6 +645,11 @@ print_setup_failure_ending() {
645 printf '\nComposio agent login complete.\n'
646 fi
647 warn "Automatic PATH setup for $requested_shell failed. The Composio CLI is installed and unaffected."
648 + # The delegated CLI's own output is captured, so point at the channel that
649 + # replays it instead of leaving the failure undiagnosable.
650 + if ! is_true "${COMPOSIO_DEBUG:-}"; then
651 + warn 'Re-run with COMPOSIO_DEBUG=1 for details.'
652 + fi
653 if [ "$install_agent" = 1 ]; then
654 printf '\nRun composio from its installed location:\n\n %s --help\n' "$(shell_quote "$exe")" >&2
655 else
test/install-sh-release-resolution.test.sh
+118 -14
@@ -54,6 +54,34 @@ wait_for_file() {
54 fail "$label"
55 }
56
57 +# The single confirmation both setup paths print: it names the startup files
58 +# that now carry the managed block and never leaks internal vocabulary.
59 +configured_line() {
60 + case $1 in
61 + zsh) printf 'Configured zsh shell setup in ~/.zshrc.\n' ;;
62 + bash) printf 'Configured bash shell setup in ~/.bashrc and ~/.bash_profile.\n' ;;
63 + fish) printf 'Configured fish shell setup in ~/.config/fish/config.fish.\n' ;;
64 + *) fail "configured_line: unknown shell $1" ;;
65 + esac
66 +}
67 +
68 +# macOS Terminal.app starts bash as a login shell, which reads only the first
69 +# existing of ~/.bash_profile, ~/.bash_login, ~/.profile and never ~/.bashrc.
70 +# Probe a real login bash over the sandboxed HOME to prove the PATH entry
71 +# actually lands somewhere it reads.
72 +assert_login_bash_path() {
73 + local home=$1
74 + local bin=$2
75 + local label=$3
76 + local login_path
77 + login_path=$(env -i HOME="$home" PATH=/usr/bin:/bin bash -lc 'printf %s "$PATH"') ||
78 + fail "$label (login bash probe failed)"
79 + case ":$login_path:" in
80 + *":$bin:"*) ;;
81 + *) fail "$label (login bash PATH lacks $bin: $login_path)" ;;
82 + esac
83 +}
84 +
85 for script in "$repo_root/install.sh" "$repo_root"/install/*.sh; do
86 [[ $(tail -n 1 "$script") == 'main "$@"' ]] || fail "$script must end with main \"\$@\""
87 [[ $(grep -c '^main "\$@"$' "$script") -eq 1 ]] || fail "$script must contain one main entry point"
@@ -317,11 +345,15 @@ install)
345 write_block "$HOME/.config/fish/config.fish" "set --export PATH \"$COMPOSIO_BIN_DIR\" \$PATH"
346 ;;
347 bash)
348 + # Login bash never reads .bashrc, so the CLI also configures a
349 + # login-mode file, creating ~/.bash_profile when no override exists.
350 + # (The real CLI additionally seeds a ~/.profile passthrough into a file
351 + # it creates; that belongs to the CLI and is covered by its unit tests.)
352 write_block "$HOME/.bashrc" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
321 - if [ -f "$HOME/.bash_profile" ]; then
322 - write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
323 - elif [ -f "$HOME/.bash_login" ]; then
353 + if [ ! -f "$HOME/.bash_profile" ] && [ -f "$HOME/.bash_login" ]; then
354 write_block "$HOME/.bash_login" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
355 + else
356 + write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\""
357 fi
358 ;;
359 esac
@@ -444,12 +476,19 @@ EOF
476 [[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"
477 assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"
478 grep -Fq "|installer|$bin_dir|install --shell bash" "$composio_log" || fail "$interpreter_name default auto delegation"
447 - assert_contains "$output" 'Configured bash shell setup (cli).' "$interpreter_name default auto confirmation"
479 + assert_contains "$output" "$(configured_line bash)" "$interpreter_name default auto confirmation"
480 + assert_not_contains "$output" '(cli)' "$interpreter_name confirmation must not leak internal labels"
481 + assert_not_contains "$output" '(fallback)' "$interpreter_name confirmation must not leak internal labels"
482 # Inherited-PATH contract: the installer prepends the bin dir to its own PATH
483 # for delegated CLI calls, but the ending must reflect only the PATH the
484 # invoking terminal inherited, which does not contain the bin dir here.
485 assert_tail "$output" "$case_b_tail" "$interpreter_name default auto Case B tail"
486 grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bashrc" || fail "$interpreter_name delegated default flow rc written by the CLI"
487 + # A login bash reads none of ~/.bashrc, so the delegated path must reach a
488 + # login-mode startup file as well.
489 + grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bash_profile" ||
490 + fail "$interpreter_name delegated default flow login file written by the CLI"
491 + assert_login_bash_path "$home" "$bin_dir" "$interpreter_name delegated default flow login shell"
492 assert_not_contains "$output" 'Updated ~/.bashrc' "$interpreter_name delegated default flow must not rewrite rc files inline"
493 [[ $(wc -l <"$composio_log") -eq 3 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
494 grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"
@@ -537,7 +576,7 @@ EOF
576 reset_case
577 CASE_HELP=0
578 help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)
540 - assert_contains "$help_suppressed" 'Configured bash shell setup (cli).' "$interpreter_name help suppression keeps setup status"
579 + assert_contains "$help_suppressed" "$(configured_line bash)" "$interpreter_name help suppression keeps setup status"
580 assert_not_contains "$help_suppressed" 'composio login' "$interpreter_name help suppression removes the final block"
581 assert_not_contains "$help_suppressed" 'Open a new terminal' "$interpreter_name help suppression removes the final block"
582
@@ -627,7 +666,7 @@ EOF
666 variant_output=$(run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins 2>&1)
667 grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||
668 fail "$interpreter_name $shell_name variant delegation"
630 - assert_contains "$variant_output" "Configured $shell_name shell setup (cli)." "$interpreter_name $shell_name variant confirmation"
669 + assert_contains "$variant_output" "$(configured_line "$shell_name")" "$interpreter_name $shell_name variant confirmation"
670 assert_not_contains "$variant_output" 'Required next step' "$interpreter_name $shell_name variant must not print setup guidance"
671 assert_not_contains "$variant_output" 'Optional shell setup' "$interpreter_name $shell_name variant must not print setup guidance"
672 done
@@ -638,7 +677,7 @@ EOF
677 direct_bin="$case_root/direct-shell-bin"
678 direct_output=$(run_installer "$direct_home" "$case_root/direct-shell-install" "$direct_bin" "$stable_tag" 2>&1)
679 grep -Fq "|installer|$direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL delegation"
641 - assert_contains "$direct_output" 'Configured zsh shell setup (cli).' "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
680 + assert_contains "$direct_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation"
681 assert_not_contains "$direct_output" 'Required next step' "$interpreter_name COMPOSIO_INSTALL_SHELL must not print setup guidance"
682 assert_tail "$direct_output" "$case_b_tail" "$interpreter_name COMPOSIO_INSTALL_SHELL Case B tail"
683 grep -Fq "export PATH=\"$direct_bin:\$PATH\"" "$direct_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL CLI-written block"
@@ -650,7 +689,7 @@ EOF
689 direct_fallback_home="$case_root/direct-fallback-home"
690 direct_fallback_output=$(run_installer "$direct_fallback_home" "$case_root/direct-fallback-install" "$case_root/direct-fallback-bin" "$stable_tag" 2>&1)
691 grep -Fqx '# Composio CLI' "$direct_fallback_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL unsupported CLI fallback"
653 - assert_contains "$direct_fallback_output" 'Configured zsh shell setup (fallback).' "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation"
692 + assert_contains "$direct_fallback_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation"
693
694 reset_case
695 CASE_INSTALL_SHELL=fish
@@ -726,7 +765,7 @@ EOF
765 auto_output=$(run_installer "$auto_home" "$auto_install" "$auto_bin" "$stable_tag" 2>&1)
766 grep -Fq "|installer|$auto_bin|install --shell $auto_shell" "$composio_log" ||
767 fail "$interpreter_name auto $auto_shell delegation"
729 - assert_contains "$auto_output" "Configured $auto_shell shell setup (cli)." "$interpreter_name auto $auto_shell confirmation"
768 + assert_contains "$auto_output" "$(configured_line "$auto_shell")" "$interpreter_name auto $auto_shell confirmation"
769 assert_tail "$auto_output" "$case_b_tail" "$interpreter_name auto $auto_shell Case B tail"
770 done
771
@@ -818,8 +857,9 @@ EOF
857 # Pinned old CLI: supports --shell but ignores the invocation-origin hint,
858 # prints its own boxed restart hint, and exits 0 without reconciling. A
859 # relative COMPOSIO_BIN_DIR must never reach setup raw; the installer must
821 - # detect the unreconciled startup file and repair it inline; its plain final
822 - # block prints after the old hint and supersedes it.
860 + # detect the unreconciled startup file and repair it inline. The delegated
861 + # command's own presentation never reaches the user: the installer owns its
862 + # output and its plain final block is the only ending.
863 reset_case
864 CASE_INSTALL_HINT=1
865 CASE_INSTALL_RECONCILE=0
@@ -832,10 +872,73 @@ EOF
872 fail "$interpreter_name old-CLI setup must receive the resolved absolute bin dir"
873 grep -Fq "export PATH=\"$oldcli_work/rel-bin:\$PATH\"" "$oldcli_home/.bashrc" ||
874 fail "$interpreter_name old-CLI delegation must be reconciled inline with the absolute bin dir"
835 - assert_contains "$oldcli_output" 'Configured bash shell setup (fallback).' "$interpreter_name old-CLI reconciliation disclosure"
836 - assert_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name old-CLI restart hint passes through"
875 + assert_contains "$oldcli_output" "$(configured_line bash)" "$interpreter_name old-CLI reconciliation disclosure"
876 + assert_not_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name delegated CLI output must not leak"
877 assert_tail "$oldcli_output" "$case_b_tail" "$interpreter_name old-CLI hint superseded by the installer tail"
878
879 + # The suppressed delegated output stays available for troubleshooting.
880 + reset_case
881 + CASE_INSTALL_HINT=1
882 + CASE_DEBUG=1
883 + delegated_debug_output=$(run_installer "$case_root/delegated-debug-home" "$case_root/delegated-debug-install" "$case_root/delegated-debug-bin" "$stable_tag" 2>&1)
884 + assert_contains "$delegated_debug_output" 'delegated shell setup exited 0' "$interpreter_name debug reports the delegated exit status"
885 + assert_contains "$delegated_debug_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name debug replays the captured delegated output"
886 + assert_contains "$delegated_debug_output" '+ shell setup source: cli' "$interpreter_name debug keeps the setup-source distinction"
887 +
888 + # --- Login-shell reachability for bash (macOS Terminal.app) ---
889 +
890 + # Inline path, virgin home: ~/.bashrc alone is unreachable from a login bash,
891 + # so the installer must also create a login-mode startup file.
892 + reset_case
893 + CASE_SHELL_CAPABILITY=unsupported
894 + CASE_SHELL_VALUE=/bin/bash
895 + bash_login_home="$case_root/bash-login-home"
896 + bash_login_bin="$case_root/bash-login-bin"
897 + bash_login_output=$(run_installer "$bash_login_home" "$case_root/bash-login-install" "$bash_login_bin" "$stable_tag" 2>&1)
898 + grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bashrc" ||
899 + fail "$interpreter_name inline bash setup must configure .bashrc"
900 + grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bash_profile" ||
901 + fail "$interpreter_name inline bash setup must configure a login-mode startup file"
902 + assert_login_bash_path "$bash_login_home" "$bash_login_bin" "$interpreter_name inline bash login shell"
903 + assert_contains "$bash_login_output" "$(configured_line bash)" "$interpreter_name inline bash names both startup files"
904 + [[ ! -e "$bash_login_home/.profile" ]] || fail "$interpreter_name inline bash setup must not create ~/.profile"
905 +
906 + # A created ~/.bash_profile shadows an existing ~/.profile, so it must keep
907 + # sourcing it — and must never rewrite ~/.profile itself.
908 + reset_case
909 + CASE_SHELL_CAPABILITY=unsupported
910 + CASE_SHELL_VALUE=/bin/bash
911 + bash_profile_home="$case_root/bash-profile-home"
912 + bash_profile_bin="$case_root/bash-profile-bin"
913 + mkdir -p "$bash_profile_home"
914 + printf '%s\n' 'export DISTRO_PROFILE=1' >"$bash_profile_home/.profile"
915 + run_installer "$bash_profile_home" "$case_root/bash-profile-install" "$bash_profile_bin" "$stable_tag" >/dev/null 2>&1
916 + grep -Fq '. "$HOME/.profile"' "$bash_profile_home/.bash_profile" ||
917 + fail "$interpreter_name a created .bash_profile must keep sourcing ~/.profile"
918 + [[ $(<"$bash_profile_home/.profile") == 'export DISTRO_PROFILE=1' ]] ||
919 + fail "$interpreter_name ~/.profile must not be modified"
920 + assert_login_bash_path "$bash_profile_home" "$bash_profile_bin" "$interpreter_name shadowed profile login shell"
921 + shadowed_profile_value=$(env -i HOME="$bash_profile_home" PATH=/usr/bin:/bin bash -lc 'printf %s "${DISTRO_PROFILE:-}"')
922 + [[ $shadowed_profile_value == 1 ]] ||
923 + fail "$interpreter_name a created .bash_profile must not shadow ~/.profile content"
924 +
925 + # An existing ~/.bash_login is the login file bash reads, so it is reused and
926 + # no ~/.bash_profile is invented in front of it.
927 + reset_case
928 + CASE_SHELL_CAPABILITY=unsupported
929 + CASE_SHELL_VALUE=/bin/bash
930 + bash_login_only_home="$case_root/bash-login-only-home"
931 + bash_login_only_bin="$case_root/bash-login-only-bin"
932 + mkdir -p "$bash_login_only_home"
933 + printf '%s\n' 'export LOGIN_OVERRIDE=1' >"$bash_login_only_home/.bash_login"
934 + bash_login_only_output=$(run_installer "$bash_login_only_home" "$case_root/bash-login-only-install" "$bash_login_only_bin" "$stable_tag" 2>&1)
935 + grep -Fq "export PATH=\"$bash_login_only_bin:\$PATH\"" "$bash_login_only_home/.bash_login" ||
936 + fail "$interpreter_name existing .bash_login must receive the managed block"
937 + [[ ! -e "$bash_login_only_home/.bash_profile" ]] ||
938 + fail "$interpreter_name an existing .bash_login must not be shadowed by a new .bash_profile"
939 + assert_contains "$bash_login_only_output" 'Configured bash shell setup in ~/.bashrc and ~/.bash_login.' "$interpreter_name .bash_login disclosure"
940 + assert_login_bash_path "$bash_login_only_home" "$bash_login_only_bin" "$interpreter_name .bash_login login shell"
941 +
942 # --- Setup write failures stay non-fatal (KD3/KD4) ---
943
944 # Delegated path: CLI --shell fails, inline fallback also fails.
@@ -849,6 +952,7 @@ EOF
952 fail "$interpreter_name delegated setup failure must keep the install successful"
953 [[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary"
954 assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning"
955 + assert_contains "$wf_delegated_output" 'COMPOSIO_DEBUG=1' "$interpreter_name delegated setup failure points at the captured output"
956 assert_tail "$wf_delegated_output" $'To get started, run:\n\n '"$wf_delegated_install/composio login" "$interpreter_name delegated setup failure recovery tail"
957
958 # Inline path: helper failure inside a conditional must propagate explicitly.
@@ -970,7 +1074,7 @@ export PATH=\"$malformed_bin:\$PATH\"" ]] || fail "$interpreter_name malformed b
1074 printf '%s\n' 'alias stale-guard=1' '' '# Composio CLI' 'export PATH="/stale/old-bin:$PATH"' >"$stale_home/.zshrc"
1075 stale_output=$(run_installer "$stale_home" "$case_root/stale-delegated-install" "$stale_bin" "$stable_tag" 2>&1)
1076 grep -Fq "|installer|$stale_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name stale delegation still delegates first"
973 - assert_contains "$stale_output" 'Configured zsh shell setup (fallback).' "$interpreter_name stale delegation reconciles inline"
1077 + assert_contains "$stale_output" "$(configured_line zsh)" "$interpreter_name stale delegation reconciles inline"
1078 [[ $(grep -Fc '# Composio CLI' "$stale_home/.zshrc") -eq 1 ]] || fail "$interpreter_name stale reconcile keeps one marker block"
1079 grep -Fq "export PATH=\"$stale_bin:\$PATH\"" "$stale_home/.zshrc" || fail "$interpreter_name stale reconcile names the current bin dir"
1080 if grep -Fq '/stale/old-bin' "$stale_home/.zshrc"; then
ts/e2e-tests/cli/install/e2e.test.ts
+8
@@ -103,14 +103,22 @@ if (config.mode === 'local' && config.shell === 'bash') {
103 async () => {
104 // Docker execs typically leave $SHELL unset, so every default-flow
105 // invocation exports it explicitly for the auto-detection contract.
106 + // A login bash never reads ~/.bashrc, so a virgin home must also come
107 + // out with a login-mode startup file; `bash -lc` (no -i) proves it.
108 const result = await run(`
109 set -eu
110 +${shellHelpers}
111 test ! -d "$HOME/.local/bin"
112 +test ! -e "$HOME/.bash_profile"
113 curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash sh
114 test -x "$HOME/.composio/composio"
115 test -L "$HOME/.local/bin/composio"
116 test "$(readlink -f "$HOME/.local/bin/composio")" = "$HOME/.composio/composio"
117 test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
118 +test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1
119 +grep -Fq '. "$HOME/.profile"' "$HOME/.bash_profile"
120 +assert_no_marker_block "$HOME/.profile"
121 +test "$(bash -lc 'command -v composio')" = "$HOME/.local/bin/composio"
122 test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
123 test "$(bash -ilc 'composio --version')" = 98.0.0
124 `);
ts/packages/cli/CHANGELOG.md
+1 -1
@@ -5,7 +5,7 @@
5 ### Minor Changes
6
7 - 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.
8 -- `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`.
8 +- `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`.
9
10 ### Patch Changes
11
ts/packages/cli/src/commands/install.cmd.ts
+58 -24
@@ -123,37 +123,64 @@ const pathBlockForShell = (shell: Shell, binDir: string, homedir: string): strin
123 : [MARKER, `export PATH="${rendered}:$PATH"`].join('\n');
124 };
125
126 -/** Bash startup-file candidates that only bash's login mode reads, in read order. */
127 -const bashLoginOverrideCandidates = (path: Path.Path, homedir: string): string[] => [
128 - path.join(homedir, '.bash_profile'),
129 - path.join(homedir, '.bash_login'),
130 -];
126 +/**
127 + * The bash startup file a login shell reads the managed PATH block from, and
128 + * whether creating it means taking over from an existing `~/.profile`.
129 + */
130 +interface BashLoginFile {
131 + readonly file: string;
132 + readonly seedsProfilePassthrough: boolean;
133 +}
134
135 /**
133 - * First existing bash login-override file, if any. `bash -ilc` reads only the
134 - * first of `.bash_profile`, `.bash_login`, `.profile` that exists — so an
135 - * existing override shadows `.profile` and common `.profile` files source
136 - * `.bashrc`, unless the PATH line also lands in the override. `.profile` is
137 - * deliberately not a candidate below: when neither override exists, bash reads
138 - * `.profile` itself, and common `.profile` files already source `.bashrc`, so
139 - * nothing needs to be written to it.
136 + * Preamble for a `~/.bash_profile` this command creates. A login bash reads
137 + * `/etc/profile` and then only the first existing of `.bash_profile`,
138 + * `.bash_login`, `.profile`, so a newly created `.bash_profile` shadows a
139 + * `.profile` the shell read until now. Sourcing it back keeps that content —
140 + * including the Debian-style `.profile` that itself sources `.bashrc` — while
141 + * leaving `.profile` (shared with every other POSIX shell) untouched.
142 + */
143 +const BASH_PROFILE_PASSTHROUGH = [
144 + '# Created by the Composio CLI installer.',
145 + '# Bash reads this file instead of ~/.profile in login shells.',
146 + 'if [ -f "$HOME/.profile" ]; then',
147 + ' . "$HOME/.profile"',
148 + 'fi',
149 +].join('\n');
150 +
151 +/**
152 + * Resolve the bash startup file that login-mode bash reads.
153 + *
154 + * Login bash never reads `.bashrc` — macOS Terminal.app starts exactly such a
155 + * shell — so the PATH block has to reach a login-mode file too. An existing
156 + * override (`.bash_profile`, then `.bash_login`) is reused; when neither
157 + * exists, `.bash_profile` is created rather than writing the shared
158 + * `.profile`, which a `.bash_profile` would shadow anyway.
159 */
141 -const resolveBashLoginOverride = (
142 - candidates: readonly string[],
160 +const resolveBashLoginFile = (
161 + path: Path.Path,
162 + homedir: string,
163 fs: FileSystem.FileSystem
144 -): Effect.Effect<string | undefined, PlatformError> =>
164 +): Effect.Effect<BashLoginFile, PlatformError> =>
165 Effect.gen(function* () {
146 - for (const candidate of candidates) {
147 - if (yield* fs.exists(candidate)) return candidate;
166 + const bashProfile = path.join(homedir, '.bash_profile');
167 + if (yield* fs.exists(bashProfile)) {
168 + return { file: bashProfile, seedsProfilePassthrough: false };
169 + }
170 + const bashLogin = path.join(homedir, '.bash_login');
171 + if (yield* fs.exists(bashLogin)) {
172 + return { file: bashLogin, seedsProfilePassthrough: false };
173 }
149 - return undefined;
174 + const profileExists = yield* fs.exists(path.join(homedir, '.profile'));
175 + return { file: bashProfile, seedsProfilePassthrough: profileExists };
176 });
177
178 +/** Bash always configures both files: `.bashrc` for interactive shells, the login file for login shells. */
179 const pathFilesForShell = (
180 path: Path.Path,
181 shell: Shell,
182 homedir: string,
156 - bashLoginOverride: string | undefined
183 + bashLoginFile: string | undefined
184 ): string[] => {
185 switch (shell) {
186 case 'zsh':
@@ -162,7 +189,7 @@ const pathFilesForShell = (
189 return [path.join(homedir, '.config', 'fish', 'config.fish')];
190 case 'bash': {
191 const bashrc = path.join(homedir, '.bashrc');
165 - return bashLoginOverride ? [bashrc, bashLoginOverride] : [bashrc];
192 + return bashLoginFile ? [bashrc, bashLoginFile] : [bashrc];
193 }
194 }
195 };
@@ -579,10 +606,9 @@ export const installShellIntegration = (params: {
606 completionScript = lines.length > 0 ? Arr.join(lines, '\n') : undefined;
607 }
608
582 - const bashLoginOverride =
583 - shell === 'bash'
584 - ? yield* resolveBashLoginOverride(bashLoginOverrideCandidates(path, os.homedir), fs)
585 - : undefined;
609 + const bashLoginFile =
610 + shell === 'bash' ? yield* resolveBashLoginFile(path, os.homedir, fs) : undefined;
611 + const bashLoginOverride = bashLoginFile?.file;
612 const pathFiles = pathFilesForShell(path, shell, os.homedir, bashLoginOverride);
613 const config = buildShellConfig(path, shell, pathFiles, binDir, completionScript, os.homedir);
614
@@ -631,6 +657,14 @@ export const installShellIntegration = (params: {
657 skipPathWriteForReachability,
658 });
659 const { replacementsByTarget, loginOverrideWritten } = writePlan;
660 + // A `.bash_profile` created here takes over from an existing `~/.profile`,
661 + // so it leads with the passthrough that keeps sourcing it.
662 + if (
663 + bashLoginFile?.seedsProfilePassthrough === true &&
664 + writePlan.appendPathFiles.includes(bashLoginFile.file)
665 + ) {
666 + pushBlock(bashLoginFile.file, BASH_PROFILE_PASSTHROUGH);
667 + }
668 for (const filePath of writePlan.appendPathFiles) {
669 pushBlock(filePath, config.pathBlock);
670 }
ts/packages/cli/test/src/commands/install.cmd.test.ts
+40 -2
@@ -148,17 +148,55 @@ describe('CLI: composio install', () => {
148
149 describe('[When] bash has neither .bash_profile nor .bash_login', () => {
150 layer(InstallTestLive())(it => {
151 - it.scoped('[Then] only .bashrc is created', () =>
151 + // A login bash (macOS Terminal.app's default) never reads .bashrc, so
152 + // the PATH block only reaches it through a created .bash_profile.
153 + it.scoped('[Then] .bash_profile is created alongside .bashrc', () =>
154 Effect.gen(function* () {
155 const os = yield* NodeOs;
156 vi.stubEnv('SHELL', '/bin/bash');
157 + const expectedBinDir = expectedRuntimeBinDir();
158
159 yield* install();
160
161 const fs = yield* FileSystem.FileSystem;
162 + const bashProfilePath = path.join(os.homedir, '.bash_profile');
163 expect(yield* fs.exists(path.join(os.homedir, '.bashrc'))).toBe(true);
160 - expect(yield* fs.exists(path.join(os.homedir, '.bash_profile'))).toBe(false);
164 + expect(yield* fs.exists(bashProfilePath)).toBe(true);
165 expect(yield* fs.exists(path.join(os.homedir, '.bash_login'))).toBe(false);
166 +
167 + const bashProfileContents = yield* fs.readFileString(bashProfilePath);
168 + expect(bashProfileContents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
169 + // No ~/.profile existed, so nothing had to be sourced back.
170 + expect(bashProfileContents).not.toContain('.profile');
171 + })
172 + );
173 + });
174 + });
175 +
176 + describe('[When] bash has no login file but an existing ~/.profile', () => {
177 + layer(InstallTestLive())(it => {
178 + it.scoped('[Then] the created .bash_profile sources ~/.profile, which stays untouched', () =>
179 + Effect.gen(function* () {
180 + const os = yield* NodeOs;
181 + const fs = yield* FileSystem.FileSystem;
182 + vi.stubEnv('SHELL', '/bin/bash');
183 + const expectedBinDir = expectedRuntimeBinDir();
184 +
185 + const profilePath = path.join(os.homedir, '.profile');
186 + yield* fs.writeFileString(profilePath, '# distro profile\n');
187 +
188 + yield* install();
189 +
190 + const bashProfileContents = yield* fs.readFileString(
191 + path.join(os.homedir, '.bash_profile')
192 + );
193 + expect(bashProfileContents).toContain('. "$HOME/.profile"');
194 + expect(bashProfileContents).toContain(`export PATH="${expectedBinDir}:$PATH"`);
195 + // The passthrough must precede the managed block it leads into.
196 + expect(bashProfileContents.indexOf('. "$HOME/.profile"')).toBeLessThan(
197 + bashProfileContents.indexOf('# Composio CLI')
198 + );
199 + expect(yield* fs.readFileString(profilePath)).toBe('# distro profile\n');
200 })
201 );
202 });