@devries-cameron20 / composio-1 / commits / 27706a508
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.

fix(install): stop swallowing the CLI's PATH guidance (#3951)

This PR: - follows up https://github.com/ComposioHQ/composio/pull/3943, replacing its hardcoded message with a fix for the cause it worked around - stops `install.sh` redirecting `composio install`'s stderr to a temp file — that redirect is what silenced the command, since the CLI gates every log, note and outro on stderr being a terminal, so the captured file was always empty and the replay printed nothing - probes `"$exe" --version` before delegating, so a binary that cannot run still falls back to inline setup without spilling loader errors — the reason the redirect existed in the first place - makes `composio install` fall back to plain `ui.error` lines when there is nothing to decorate, so container and CI installs that pipe the session to a build log still get the report; interactive output is unchanged. `canDecorate` is constant for a run, so each channel binds to its decorated or plain form once rather than re-testing per message - drops the unconditional "Composio was added to your PATH" line, which printed on three paths where nothing was written: shell-not-detected and unsafe-install-dir (both exit 0 after reporting manual setup), and the inline fallback's unsupported-shell and unwritable-rc branches - adds regression tests using the production `makeTerminalUI` implementation with captured streams, so the real decoration gate is exercised — the shared test double reports `canDecorate: false` but prints everything anyway, which is why this went unnoticed through two prior attempts ## Context Measured against the released binary, `composio install` writes 0 bytes when its stderr is not a terminal, and exits 0 without touching any rc file when `$SHELL` is unset. Both were invisible to the installer: | case | exit | stderr bytes | PATH block written | | --- | --- | --- | --- | | `2>file`, as `install.sh` did | 0 | 0 | yes | | `$SHELL` unset | 0 | 0 | no | | stderr on a terminal | 0 | full report | yes | With the redirect gone, the delegated path prints what the user was missing — `Updated ~/.zshrc` and `Restart your shell to apply changes` / `source ~/.zshrc` — and the manual-setup text on the paths where PATH genuinely was not touched. The closing block no longer needs a PATH claim of its own, and the fallback keeps printing its own `refresh_command`. 067c67b69552e8f385186422f6ed45bcbd5cf610 already tried to surface this output by capturing it to a temp file and replaying it on success. That replay has been a no-op for the same reason, so this guidance has never reached a user since the delegation was introduced. ## How Has This Been Tested? - new tests fail with `expected '' to contain 'PATH: will add'` (empty output — the production bug) without the `install.cmd.ts` change, and pass with it - full CLI suite: 957 passed, 1 skipped; `pnpm typecheck` 14/14; `validate:boundaries`, eslint and prettier clean, no new eslint disables - released binary in a sandboxed `$HOME`: stderr to a file yields 0 bytes; stderr on a pty yields the full report - CLI from source with stderr captured: 155 bytes of plain guidance where it previously wrote nothing; decorated output on a terminal unchanged - `install.sh` driven through a harness built from the real script under a pty: a working binary's stderr reaches the terminal, a broken binary's loader noise stays suppressed and the fallback writes the PATH block and prints `source ~/.zshrc`. The same harness against `next` shows the swallow. No changeset: `@composio/cli` is Changesets-ignored and `install.sh` is not a published package. The CLI note went into `CHANGELOG.md` directly. `install.sh` is served from `next`, so the installer half of this reaches new installs on merge and works with already-released binaries. The `install.cmd.ts` half only affects captured-stderr installs and rides the next CLI release.

Alberto Schiabel committed Jul 28, 2026 at 21:40 UTC 27706a508127cb97d7cb6f337228bb4416d84682
5 files changed +161 -25
install.sh
+14 -6
@@ -306,12 +306,18 @@ success "Composio CLI was installed successfully to $Bold_Green$(tildify "$exe")
306 # - Idempotent PATH setup in the correct rc file
307 # - Shell completions installation
308 # If the binary can't run (e.g. missing runtime), fall back to inline setup.
309 +#
310 +# Run it with stderr left on the terminal. `composio install` reports which rc
311 +# file it changed and how to reload the shell, and it treats a redirected stderr
312 +# as "nobody is watching" — capturing that stream, even to replay it later, is
313 +# what makes the PATH guidance disappear. The version probe keeps a binary that
314 +# cannot run at all from spilling loader errors before the fallback takes over.
315
316 echo
317
312 -install_err=$(mktemp)
313 -if COMPOSIO_INSTALL_DIR="$COMPOSIO_INSTALL_DIR" "$exe" install 2>"$install_err"; then
314 - cat "$install_err" >&2 # Show CLI's TerminalUI output on success
318 +if "$exe" --version >/dev/null 2>&1 &&
319 + COMPOSIO_INSTALL_DIR="$COMPOSIO_INSTALL_DIR" "$exe" install; then
320 + : # the CLI printed its own shell-integration guidance
321 else
322 info "Setting up shell integration..."
323
@@ -402,7 +408,6 @@ else
408 esac
409
410 fi
405 -rm -f "$install_err"
411
412 if [[ $install_plugins = true ]]; then
413 echo
@@ -421,8 +426,11 @@ if [[ $install_agent = true ]]; then
426 fi
427
428 echo
424 -info "Composio was added to your PATH — restart your shell (or open a new terminal) for it to take effect."
425 -info "Then, to get started, run:"
429 +# No PATH claim here: whichever branch ran above already reported what it did to
430 +# which file, and whether a reload is needed. Restating it unconditionally would
431 +# promise a configured PATH even on the branches that only printed manual
432 +# instructions.
433 +info "To get started, run:"
434 echo
435
436 if [[ ${refresh_command:-} ]]; then
test/install-sh-release-resolution.test.sh
+63 -3
@@ -151,6 +151,9 @@ printf '%s\n' "$*" >> "$TEST_COMPOSIO_LOG"
151
152 case "${1:-}" in
153 install)
154 + if [[ -n "${TEST_INSTALL_STDERR:-}" ]]; then
155 + printf '%s\n' "$TEST_INSTALL_STDERR" >&2
156 + fi
157 exit 0
158 ;;
159 setup)
@@ -161,8 +164,11 @@ setup)
164 exit "${TEST_SETUP_EXIT:-0}"
165 ;;
166 --version|version)
167 + if [[ -n "${TEST_VERSION_STDERR:-}" ]]; then
168 + printf '%s\n' "$TEST_VERSION_STDERR" >&2
169 + fi
170 echo 'composio fake 98.0.0'
165 - exit 0
171 + exit "${TEST_VERSION_EXIT:-0}"
172 ;;
173 *)
174 exit 0
@@ -207,11 +213,15 @@ run_installer() {
213 COMPOSIO_GITHUB_API_BASE_URL="$api_base" \
214 COMPOSIO_GITHUB_OWNER='FakeOwner' \
215 COMPOSIO_GITHUB_REPO='fake-repo' \
216 + TEST_INSTALL_STDERR="${TEST_INSTALL_STDERR:-}" \
217 TEST_SETUP_EXIT="${TEST_SETUP_EXIT:-0}" \
218 + TEST_VERSION_EXIT="${TEST_VERSION_EXIT:-0}" \
219 + TEST_VERSION_STDERR="${TEST_VERSION_STDERR:-}" \
220 bash "$repo_root/install.sh" "$@"
221 }
222
214 -output=$(run_installer "$home_dir" "$install_dir" 2>&1)
223 +install_guidance='shell integration guidance from composio install'
224 +output=$(TEST_INSTALL_STDERR="$install_guidance" run_installer "$home_dir" "$install_dir" 2>&1)
225
226 printf '%s\n' "$output"
227
@@ -247,6 +257,24 @@ if grep -q "$tag_without_release" "$curl_log"; then
257 exit 1
258 fi
259
260 +if ! grep -qxF -- '--version' "$composio_log"; then
261 + echo 'Expected installer to probe the downloaded CLI with --version.' >&2
262 + cat "$composio_log" >&2
263 + exit 1
264 +fi
265 +
266 +if ! grep -qxF 'install' "$composio_log"; then
267 + echo 'Expected installer to delegate shell integration to composio install.' >&2
268 + cat "$composio_log" >&2
269 + exit 1
270 +fi
271 +
272 +if ! grep -qF "$install_guidance" <<<"$output"; then
273 + echo 'Expected composio install stderr guidance to remain visible.' >&2
274 + printf '%s\n' "$output" >&2
275 + exit 1
276 +fi
277 +
278 expected_setup='setup --target auto --yes --if-present'
279 if ! grep -qxF "$expected_setup" "$composio_log"; then
280 echo "Expected installer to invoke: composio $expected_setup" >&2
@@ -254,6 +282,38 @@ if ! grep -qxF "$expected_setup" "$composio_log"; then
282 exit 1
283 fi
284
285 +failed_probe_home="$tmpdir/home-failed-probe"
286 +failed_probe_install="$tmpdir/install-failed-probe"
287 +mkdir -p "$failed_probe_home" "$failed_probe_install"
288 +: > "$failed_probe_home/.bashrc"
289 +: > "$composio_log"
290 +loader_error='loader error from an unusable composio binary'
291 +failed_probe_output=$(
292 + TEST_VERSION_EXIT=126 \
293 + TEST_VERSION_STDERR="$loader_error" \
294 + run_installer "$failed_probe_home" "$failed_probe_install" --no-plugins 2>&1
295 +)
296 +if grep -qF "$loader_error" <<<"$failed_probe_output"; then
297 + echo 'Expected the failed binary probe to suppress loader errors.' >&2
298 + printf '%s\n' "$failed_probe_output" >&2
299 + exit 1
300 +fi
301 +if grep -qxF 'install' "$composio_log"; then
302 + echo 'Expected a failed binary probe to skip composio install.' >&2
303 + cat "$composio_log" >&2
304 + exit 1
305 +fi
306 +if ! grep -qF 'Setting up shell integration...' <<<"$failed_probe_output"; then
307 + echo 'Expected a failed binary probe to select inline shell integration.' >&2
308 + printf '%s\n' "$failed_probe_output" >&2
309 + exit 1
310 +fi
311 +if ! grep -qxF '# Composio CLI' "$failed_probe_home/.bashrc"; then
312 + echo 'Expected inline shell integration to update .bashrc.' >&2
313 + cat "$failed_probe_home/.bashrc" >&2
314 + exit 1
315 +fi
316 +
317 no_plugins_home="$tmpdir/home-no-plugins"
318 no_plugins_install="$tmpdir/install-no-plugins"
319 mkdir -p "$no_plugins_home" "$no_plugins_install"
@@ -290,4 +350,4 @@ if ! grep -q 'Composio CLI was installed, but agent plugin setup failed' <<<"$fa
350 exit 1
351 fi
352
293 -printf 'install.sh release fallback and plugin setup tests passed\n'
353 +printf 'install.sh release fallback, shell integration, and plugin setup tests passed\n'
ts/packages/cli/CHANGELOG.md
+1
@@ -19,6 +19,7 @@
19 - Preserve the original CLI diagnostic when an adjacent source map is malformed or unusable instead of letting optional source-map enrichment abort error capture. Source-map enrichment is now best-effort end to end: a malformed, invalid, or unreadable `.map`, and a valid map pointing at an original source that was never shipped, all degrade to the raw stack location. `captureErrors` can no longer fail.
20 - Fix source-map resolution on Windows: original source paths are now resolved with the platform path separator instead of a hardcoded `/`, and the `node_modules` filter no longer mistakes directories such as `node_modules_local` for real dependency paths.
21 - Make `composio version --check` report `checkStatus: "unknown"` when GitHub cannot confirm the latest stable release, preserve the last successful cache on failed refreshes, and avoid racing the command with the startup update check.
22 +- Keep `composio install` guidance visible when its output is captured. The command reports which rc file it changed and how to reload the shell, but suppressed all of it when stderr was not a terminal — so installers, containers, and CI logs saw nothing and users were left with `command not found`. Those lines now fall back to plain, undecorated output.
23 - Make multi-account selection a stable CLI feature: `execute`, `listen`, and `link --alias` no longer honor the old experimental toggle; `proxy` now accepts `--account <alias|word_id|connected-account-id>`; and duplicate-alias link errors explain how to select the existing account.
24 - 8467efd: Fix `composio whoami` reporting the API key's home organization after `composio orgs switch`. Session info requests now forward the selected global organization.
25 - 5f004ff: Drop `COMPOSIO_UPSERT_RECIPE` and `COMPOSIO_GET_RECIPE` from the CLI meta-tool list. These slugs were removed from `@composio/client` (alpha.74), so listing them broke the type-checked CLI build.
ts/packages/cli/src/commands/install.cmd.ts
+28 -16
@@ -169,6 +169,20 @@ export const installShellIntegration = (params: {
169 const fs = yield* FileSystem.FileSystem;
170 const path = yield* Path.Path;
171
172 + // Everything this command prints is a report of what it changed on disk, so
173 + // it has to reach the user even when stderr is not a terminal: install.sh
174 + // runs it as a subprocess, and container/CI installs pipe the whole session
175 + // to a build log. Decoration stays the interactive default; `ui.error`
176 + // writes the same text unformatted when there is nothing to decorate.
177 + const { canDecorate } = yield* ui.capabilities;
178 + const plain = (prefix: string) => (message: string) => ui.error(`${prefix}${message}`);
179 + const step = canDecorate ? ui.log.step : ui.error;
180 + const success = canDecorate ? ui.log.success : ui.error;
181 + const warn = canDecorate ? ui.log.warn : plain('warning: ');
182 + const failure = canDecorate ? ui.log.error : plain('error: ');
183 + const note = (body: string, title: string) =>
184 + canDecorate ? ui.note(body, title) : ui.error(`${title}:\n${body}`);
185 +
186 yield* ui.intro('composio install');
187
188 // Detect install directory — either from env or default ~/.composio
@@ -176,7 +190,7 @@ export const installShellIntegration = (params: {
190 const installDir = process.env.COMPOSIO_INSTALL_DIR ?? path.join(os.homedir, '.composio');
191
192 if (isUnsafePath(installDir)) {
179 - yield* ui.log.error(
193 + yield* failure(
194 'COMPOSIO_INSTALL_DIR contains unsafe characters and cannot be written to shell config.'
195 );
196 yield* ui.outro('Aborted.');
@@ -186,10 +200,8 @@ export const installShellIntegration = (params: {
200 // Detect user shell
201 const shell = detectShell(path);
202 if (!shell) {
189 - yield* ui.log.warn(
190 - 'Could not detect your shell. Manually add the following to your shell config:'
191 - );
192 - yield* ui.note(
203 + yield* warn('Could not detect your shell. Manually add the following to your shell config:');
204 + yield* note(
205 `export COMPOSIO_INSTALL_DIR="${installDir}"\nexport PATH="$COMPOSIO_INSTALL_DIR:$PATH"`,
206 'PATH setup'
207 );
@@ -197,7 +209,7 @@ export const installShellIntegration = (params: {
209 return;
210 }
211
200 - yield* ui.log.step(`Detected shell: ${shell}`);
212 + yield* step(`Detected shell: ${shell}`);
213
214 // Generate completions script if requested.
215 // Lazy-import the root command to avoid a circular dependency
@@ -239,28 +251,28 @@ export const installShellIntegration = (params: {
251 const existingPathFile = existingByFile.get(config.pathFile) ?? '';
252 if (!fileContains(existingPathFile, MARKER)) {
253 pushBlock(config.pathFile, config.pathBlock);
242 - yield* ui.log.step(`PATH: will add ${tildify(installDir, os.homedir)} to $PATH`);
254 + yield* step(`PATH: will add ${tildify(installDir, os.homedir)} to $PATH`);
255 } else {
244 - yield* ui.log.step('PATH: already configured');
256 + yield* step('PATH: already configured');
257 }
258
259 if (shell === 'zsh') {
248 - yield* ui.log.step('Completions: skipped for zsh');
260 + yield* step('Completions: skipped for zsh');
261 } else if (!params.completions) {
250 - yield* ui.log.step('Completions: skipped by default (pass --completions to enable)');
262 + yield* step('Completions: skipped by default (pass --completions to enable)');
263 } else if (!config.completionBlock) {
252 - yield* ui.log.step('Completions: not available for this shell');
264 + yield* step('Completions: not available for this shell');
265 } else {
266 const existingCompletionFile = existingByFile.get(config.completionFile) ?? '';
267 if (!fileContains(existingCompletionFile, COMPLETIONS_MARKER)) {
268 pushBlock(config.completionFile, config.completionBlock);
257 - yield* ui.log.step(
269 + yield* step(
270 config.shell === 'fish'
271 ? `Completions: will install fish completions to ${tildify(config.completionFile, os.homedir)}`
272 : 'Completions: will install shell completions'
273 );
274 } else {
263 - yield* ui.log.step('Completions: already configured');
275 + yield* step('Completions: already configured');
276 }
277 }
278
@@ -286,14 +298,14 @@ export const installShellIntegration = (params: {
298 yield* fs.writeFileString(tmpPath, existingContents + appendContent);
299 yield* fs.rename(tmpPath, writeTarget);
300
289 - yield* ui.log.success(`Updated ${tildify(filePath, os.homedir)}`);
301 + yield* success(`Updated ${tildify(filePath, os.homedir)}`);
302 }
303 } else {
292 - yield* ui.log.success('Shell integration already configured — nothing to do.');
304 + yield* success('Shell integration already configured — nothing to do.');
305 }
306
307 if (blocksByFile.size > 0) {
296 - yield* ui.note(
308 + yield* note(
309 shell === 'fish'
310 ? 'exec fish'
311 : shell === 'zsh'
ts/packages/cli/test/src/commands/install.cmd.test.ts
+55
@@ -1,12 +1,33 @@
1 import path from 'node:path';
2 import process from 'node:process';
3 +import { Writable } from 'node:stream';
4 import { beforeEach, afterEach } from 'vitest';
5 import { describe, expect, layer } from '@effect/vitest';
6 import { Effect } from 'effect';
7 import { FileSystem } from '@effect/platform';
8 import { NodeOs } from 'src/services/node-os';
9 +import { makeTerminalUI } from 'src/services/terminal-ui';
10 import { cli, TestLive, MockConsole } from 'test/__utils__';
11
12 +const makeSink = (isTTY: boolean) => {
13 + const chunks: string[] = [];
14 + const sink = new Writable({
15 + write(chunk, _encoding, callback) {
16 + chunks.push(String(chunk));
17 + callback();
18 + },
19 + });
20 + return Object.assign(sink, { isTTY, chunks });
21 +};
22 +
23 +const capturedStdout = makeSink(true);
24 +const capturedStderr = makeSink(false);
25 +const capturedStderrUI = makeTerminalUI({
26 + stdin: { isTTY: true },
27 + stdout: capturedStdout,
28 + stderr: capturedStderr,
29 +});
30 +
31 describe('CLI: composio install', () => {
32 let savedShell: string | undefined;
33 let savedInstallDir: string | undefined;
@@ -14,6 +35,8 @@ describe('CLI: composio install', () => {
35 beforeEach(() => {
36 savedShell = process.env.SHELL;
37 savedInstallDir = process.env.COMPOSIO_INSTALL_DIR;
38 + capturedStdout.chunks.length = 0;
39 + capturedStderr.chunks.length = 0;
40 });
41
42 afterEach(() => {
@@ -374,6 +397,38 @@ describe('CLI: composio install', () => {
397 });
398 });
399
400 + describe('[When] stderr is captured rather than a terminal', () => {
401 + layer(TestLive({ terminalUI: capturedStderrUI }))(it => {
402 + it.scoped('[Then] still reports the rc file and how to reload the shell', () =>
403 + Effect.gen(function* () {
404 + const os = yield* NodeOs;
405 + process.env.SHELL = '/bin/zsh';
406 + process.env.COMPOSIO_INSTALL_DIR = path.join(os.homedir, '.composio');
407 +
408 + yield* cli(['install']);
409 +
410 + const output = capturedStderr.chunks.join('');
411 + expect(output).toContain('PATH: will add');
412 + expect(output).toContain('Updated ~/.zshrc');
413 + expect(output).toContain('Restart your shell to apply changes');
414 + expect(output).toContain('source ~/.zshrc');
415 + })
416 + );
417 +
418 + it.scoped('[Then] still shows manual setup instructions for an unknown shell', () =>
419 + Effect.gen(function* () {
420 + process.env.SHELL = '';
421 +
422 + yield* cli(['install']);
423 +
424 + const output = capturedStderr.chunks.join('');
425 + expect(output).toContain('Could not detect your shell');
426 + expect(output).toContain('export PATH="$COMPOSIO_INSTALL_DIR:$PATH"');
427 + })
428 + );
429 + });
430 + });
431 +
432 describe('[When] COMPOSIO_INSTALL_DIR is not set', () => {
433 layer(TestLive())(it => {
434 it.scoped('[Then] defaults to ~/.composio', () =>