Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
test(cli): cover auto shell setup default in installer e2e
jkomynoec9d5b936bc9
diff --git a/ts/e2e-tests/cli/install/e2e.test.ts b/ts/e2e-tests/cli/install/e2e.test.tsindex 33c02b136..23f078b1b 100644--- a/ts/e2e-tests/cli/install/e2e.test.ts+++ b/ts/e2e-tests/cli/install/e2e.test.ts@@ -18,6 +18,19 @@ const timeout = 600_000;let image: InstallImage | undefined;let releaseServer: InstallReleaseServer | undefined;+/**+ * POSIX helper injected into container scripts. `! grep` would not trip+ * `set -e`, so missing-marker assertions go through an explicit branch.+ */+const shellHelpers = `+assert_no_marker_block() {+ if grep -Fq '# Composio CLI' "$1" 2>/dev/null; then+ echo "unexpected Composio marker block in $1" >&2+ exit 1+ fi+}+`;+function assertSuccess(result: ExecResult): void {if (result.exitCode !== 0) {throw new Error(@@ -88,13 +101,16 @@ if (config.mode === 'local' && config.shell === 'bash') {it('installs into a virgin home and is available in a fresh login shell',async () => {+ // Docker execs typically leave $SHELL unset, so every default-flow+ // invocation exports it explicitly for the auto-detection contract.const result = await run(`set -eutest ! -d "$HOME/.local/bin"-curl -fsSL "$INSTALL_BASE_URL/install" | sh+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash shtest -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")" = 1test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"test "$(bash -ilc 'composio --version')" = 98.0.0`);@@ -104,22 +120,23 @@ test "$(bash -ilc 'composio --version')" = 98.0.0);it(- 'configures an existing bash login profile only through the bash variant',+ 'configures an existing bash login profile through the plain default install',async () => {+ // An existing ~/.bash_profile shadows Debian's ~/.profile, so a fresh+ // login shell resolves composio only if the installer configured it.const result = await run(`set -euprintf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"-output=$(curl -fsSL "$INSTALL_BASE_URL/install" | sh)-printf '%s\n' "$output" | grep -F 'Required next step for bash:'-if bash -ilc 'command -v composio' >/dev/null 2>&1; then- echo 'default installer unexpectedly configured the login shell' >&2- exit 1-fi-curl -fsSL "$INSTALL_BASE_URL/install/bash" | sh+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash sh)+ending=$(printf '%s\n' "$output" | tail -n 3)+case_b=$(printf 'Open a new terminal, then run:\n\n composio login')+test "$ending" = "$case_b"+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash shtest "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"test "$(bash -ilc 'composio --version')" = 98.0.0test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1+grep -Fx 'export PROFILE_TRAP=1' "$HOME/.bash_profile"`);assertSuccess(result);},@@ -136,6 +153,54 @@ curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_INSTALL_SHELL=bash shtest "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"test "$(bash -ilc 'composio --version')" = 98.0.0test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'falls back to install-only when $SHELL is unset',+ async () => {+ const result = await run(`+set -eu+${shellHelpers}+printf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | env -u SHELL sh)+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+if bash -ilc 'command -v composio' >/dev/null 2>&1; then+ echo 'install-only fallback unexpectedly configured the login shell' >&2+ exit 1+fi+assert_no_marker_block "$HOME/.bash_profile"+assert_no_marker_block "$HOME/.bashrc"+assert_no_marker_block "$HOME/.profile"+printf '%s\n' "$output" | grep -F "$HOME/.composio/composio login"+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'skips shell setup when COMPOSIO_INSTALL_SHELL=none despite a recognized $SHELL',+ async () => {+ const result = await run(`+set -eu+${shellHelpers}+printf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_INSTALL_SHELL=none SHELL=/bin/bash sh)+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+if bash -ilc 'command -v composio' >/dev/null 2>&1; then+ echo 'COMPOSIO_INSTALL_SHELL=none unexpectedly configured the login shell' >&2+ exit 1+fi+assert_no_marker_block "$HOME/.bash_profile"+assert_no_marker_block "$HOME/.bashrc"+assert_no_marker_block "$HOME/.profile"+printf '%s\n' "$output" | grep -F "$HOME/.composio/composio login"`);assertSuccess(result);},@@ -163,6 +228,43 @@ test -d "$HOME/.composio/local-tools-binaries"test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"test "$(zsh -ilc 'composio --version')" = 98.0.0+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'configures zsh idempotently through the plain default install when $SHELL is zsh',+ async () => {+ const result = await run(`+set -eu+test ! -d "$HOME/.local/bin"+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/zsh sh+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/zsh sh+test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1+test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+test "$(zsh -ilc 'composio --version')" = 98.0.0+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'keeps the install successful when shell setup cannot write the startup file',+ async () => {+ // A directory at ~/.zshrc blocks both delegated and inline setup.+ // Contract: binary installed, exit 0, warning, trusted absolute+ // recovery command on the verified installed executable.+ const result = await run(`+set -eu+mkdir "$HOME/.zshrc"+combined=$(curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/zsh sh 2>&1)+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+printf '%s\n' "$combined" | grep -i 'warning'+printf '%s\n' "$combined" | grep -F "$HOME/.composio/composio login"`);assertSuccess(result);},@@ -178,7 +280,7 @@ if (config.mode === 'local') {async () => {const result = await run(`set -eu-if curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; then+if curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; thenecho 'corrupted archive unexpectedly installed' >&2exit 1fi@@ -200,7 +302,7 @@ if (config.mode === 'prod' && config.version === 'latest') {const result = await run(`set -eutest ! -d "$HOME/.local/bin"-curl -fsSL "$INSTALL_BASE_URL/${route}" | sh+curl -fsSL "$INSTALL_BASE_URL/${route}" | SHELL=/bin/${config.shell} shtest -x "$HOME/.composio/composio"test -L "$HOME/.local/bin/composio"test "$(${config.shell} -ilc 'command -v composio')" = "$HOME/.local/bin/composio"@@ -216,19 +318,58 @@ ${config.shell} -ilc 'composio --version'if (config.mode === 'prod' && config.version !== 'latest') {describe(`production ${config.version} compatibility installation`, () => {it(- 'uses inline shell setup when the pinned CLI lacks install --shell',+ 'configures the login shell inline when the pinned CLI lacks install --shell',async () => {const result = await run(`set -eu-curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- "$E2E_VERSION"+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} sh -s -- "$E2E_VERSION"if "$HOME/.composio/composio" install --help | grep -q -- '--shell'; thenecho 'expected the pinned CLI to predate install --shell' >&2exit 1fi+test "$(grep -Fc '# Composio CLI' "$HOME/.${config.shell}rc")" = 1curl -fsSL "$INSTALL_BASE_URL/install/${config.shell}" | sh -s -- "$E2E_VERSION"-test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1-test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"-zsh -ilc 'composio --version'+test "$(grep -Fc '# Composio CLI' "$HOME/.${config.shell}rc")" = 1+test "$(${config.shell} -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+${config.shell} -ilc 'composio --version'+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'persists the resolved absolute bin directory through inline setup',+ async () => {+ // A relative COMPOSIO_BIN_DIR must never be persisted raw: the login+ // shell check runs from / so only an absolute PATH entry can resolve.+ const result = await run(`+set -eu+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} COMPOSIO_BIN_DIR=.composio-bin sh -s -- "$E2E_VERSION"+test -x "$HOME/.composio/composio"+test -x "$HOME/.composio-bin/composio"+test "$(grep -Fc '# Composio CLI' "$HOME/.${config.shell}rc")" = 1+test "$(cd / && ${config.shell} -ilc 'command -v composio')" = "$HOME/.composio-bin/composio"+(cd / && ${config.shell} -ilc 'composio --version')+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'keeps the pinned install successful when inline setup cannot write the startup file',+ async () => {+ // Contract: binary installed, exit 0, warning, trusted absolute+ // recovery command on the verified installed executable.+ const result = await run(`+set -eu+mkdir "$HOME/.${config.shell}rc"+combined=$(curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} sh -s -- "$E2E_VERSION" 2>&1)+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+printf '%s\n' "$combined" | grep -i 'warning'+printf '%s\n' "$combined" | grep -F "$HOME/.composio/composio login"`);assertSuccess(result);},