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
test(cli): cover auto shell setup default in installer e2e
jkomyno committed
Aug 3, 2026 at 16:54 UTC
ec9d5b936bc9f19fc785702bac940a0ac89d659f
1 file changed
+157
-16
ts/e2e-tests/cli/install/e2e.test.ts
+157
-16
@@ -18,6 +18,19 @@ const timeout = 600_000;
18
let image: InstallImage | undefined;
19
let releaseServer: InstallReleaseServer | undefined;
20
21
+/**
22
+ * POSIX helper injected into container scripts. `! grep` would not trip
23
+ * `set -e`, so missing-marker assertions go through an explicit branch.
24
+ */
25
+const shellHelpers = `
26
+assert_no_marker_block() {
27
+ if grep -Fq '# Composio CLI' "$1" 2>/dev/null; then
28
+ echo "unexpected Composio marker block in $1" >&2
29
+ exit 1
30
+ fi
31
+}
32
+`;
33
+
34
function assertSuccess(result: ExecResult): void {
35
if (result.exitCode !== 0) {
36
throw new Error(
@@ -88,13 +101,16 @@ if (config.mode === 'local' && config.shell === 'bash') {
101
it(
102
'installs into a virgin home and is available in a fresh login shell',
103
async () => {
104
+ // Docker execs typically leave $SHELL unset, so every default-flow
105
+ // invocation exports it explicitly for the auto-detection contract.
106
const result = await run(`
107
set -eu
108
test ! -d "$HOME/.local/bin"
94
-curl -fsSL "$INSTALL_BASE_URL/install" | sh
109
+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash sh
110
test -x "$HOME/.composio/composio"
111
test -L "$HOME/.local/bin/composio"
112
test "$(readlink -f "$HOME/.local/bin/composio")" = "$HOME/.composio/composio"
113
+test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
114
test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
115
test "$(bash -ilc 'composio --version')" = 98.0.0
116
`);
@@ -104,22 +120,23 @@ test "$(bash -ilc 'composio --version')" = 98.0.0
120
);
121
122
it(
107
- 'configures an existing bash login profile only through the bash variant',
123
+ 'configures an existing bash login profile through the plain default install',
124
async () => {
125
+ // An existing ~/.bash_profile shadows Debian's ~/.profile, so a fresh
126
+ // login shell resolves composio only if the installer configured it.
127
const result = await run(`
128
set -eu
129
printf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"
112
-output=$(curl -fsSL "$INSTALL_BASE_URL/install" | sh)
113
-printf '%s\n' "$output" | grep -F 'Required next step for bash:'
114
-if bash -ilc 'command -v composio' >/dev/null 2>&1; then
115
- echo 'default installer unexpectedly configured the login shell' >&2
116
- exit 1
117
-fi
118
-curl -fsSL "$INSTALL_BASE_URL/install/bash" | sh
130
+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash sh)
131
+ending=$(printf '%s\n' "$output" | tail -n 3)
132
+case_b=$(printf 'Open a new terminal, then run:\n\n composio login')
133
+test "$ending" = "$case_b"
134
+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/bash sh
135
test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
136
test "$(bash -ilc 'composio --version')" = 98.0.0
137
test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1
138
test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
139
+grep -Fx 'export PROFILE_TRAP=1' "$HOME/.bash_profile"
140
`);
141
assertSuccess(result);
142
},
@@ -136,6 +153,54 @@ curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_INSTALL_SHELL=bash sh
153
test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
154
test "$(bash -ilc 'composio --version')" = 98.0.0
155
test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1
156
+`);
157
+ assertSuccess(result);
158
+ },
159
+ timeout
160
+ );
161
+
162
+ it(
163
+ 'falls back to install-only when $SHELL is unset',
164
+ async () => {
165
+ const result = await run(`
166
+set -eu
167
+${shellHelpers}
168
+printf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"
169
+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | env -u SHELL sh)
170
+test -x "$HOME/.composio/composio"
171
+test -L "$HOME/.local/bin/composio"
172
+if bash -ilc 'command -v composio' >/dev/null 2>&1; then
173
+ echo 'install-only fallback unexpectedly configured the login shell' >&2
174
+ exit 1
175
+fi
176
+assert_no_marker_block "$HOME/.bash_profile"
177
+assert_no_marker_block "$HOME/.bashrc"
178
+assert_no_marker_block "$HOME/.profile"
179
+printf '%s\n' "$output" | grep -F "$HOME/.composio/composio login"
180
+`);
181
+ assertSuccess(result);
182
+ },
183
+ timeout
184
+ );
185
+
186
+ it(
187
+ 'skips shell setup when COMPOSIO_INSTALL_SHELL=none despite a recognized $SHELL',
188
+ async () => {
189
+ const result = await run(`
190
+set -eu
191
+${shellHelpers}
192
+printf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"
193
+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_INSTALL_SHELL=none SHELL=/bin/bash sh)
194
+test -x "$HOME/.composio/composio"
195
+test -L "$HOME/.local/bin/composio"
196
+if bash -ilc 'command -v composio' >/dev/null 2>&1; then
197
+ echo 'COMPOSIO_INSTALL_SHELL=none unexpectedly configured the login shell' >&2
198
+ exit 1
199
+fi
200
+assert_no_marker_block "$HOME/.bash_profile"
201
+assert_no_marker_block "$HOME/.bashrc"
202
+assert_no_marker_block "$HOME/.profile"
203
+printf '%s\n' "$output" | grep -F "$HOME/.composio/composio login"
204
`);
205
assertSuccess(result);
206
},
@@ -163,6 +228,43 @@ test -d "$HOME/.composio/local-tools-binaries"
228
test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1
229
test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
230
test "$(zsh -ilc 'composio --version')" = 98.0.0
231
+`);
232
+ assertSuccess(result);
233
+ },
234
+ timeout
235
+ );
236
+
237
+ it(
238
+ 'configures zsh idempotently through the plain default install when $SHELL is zsh',
239
+ async () => {
240
+ const result = await run(`
241
+set -eu
242
+test ! -d "$HOME/.local/bin"
243
+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/zsh sh
244
+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/zsh sh
245
+test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1
246
+test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
247
+test "$(zsh -ilc 'composio --version')" = 98.0.0
248
+`);
249
+ assertSuccess(result);
250
+ },
251
+ timeout
252
+ );
253
+
254
+ it(
255
+ 'keeps the install successful when shell setup cannot write the startup file',
256
+ async () => {
257
+ // A directory at ~/.zshrc blocks both delegated and inline setup.
258
+ // Contract: binary installed, exit 0, warning, trusted absolute
259
+ // recovery command on the verified installed executable.
260
+ const result = await run(`
261
+set -eu
262
+mkdir "$HOME/.zshrc"
263
+combined=$(curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/zsh sh 2>&1)
264
+test -x "$HOME/.composio/composio"
265
+test -L "$HOME/.local/bin/composio"
266
+printf '%s\n' "$combined" | grep -i 'warning'
267
+printf '%s\n' "$combined" | grep -F "$HOME/.composio/composio login"
268
`);
269
assertSuccess(result);
270
},
@@ -178,7 +280,7 @@ if (config.mode === 'local') {
280
async () => {
281
const result = await run(`
282
set -eu
181
-if curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; then
283
+if curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; then
284
echo 'corrupted archive unexpectedly installed' >&2
285
exit 1
286
fi
@@ -200,7 +302,7 @@ if (config.mode === 'prod' && config.version === 'latest') {
302
const result = await run(`
303
set -eu
304
test ! -d "$HOME/.local/bin"
203
-curl -fsSL "$INSTALL_BASE_URL/${route}" | sh
305
+curl -fsSL "$INSTALL_BASE_URL/${route}" | SHELL=/bin/${config.shell} sh
306
test -x "$HOME/.composio/composio"
307
test -L "$HOME/.local/bin/composio"
308
test "$(${config.shell} -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
@@ -216,19 +318,58 @@ ${config.shell} -ilc 'composio --version'
318
if (config.mode === 'prod' && config.version !== 'latest') {
319
describe(`production ${config.version} compatibility installation`, () => {
320
it(
219
- 'uses inline shell setup when the pinned CLI lacks install --shell',
321
+ 'configures the login shell inline when the pinned CLI lacks install --shell',
322
async () => {
323
const result = await run(`
324
set -eu
223
-curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- "$E2E_VERSION"
325
+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} sh -s -- "$E2E_VERSION"
326
if "$HOME/.composio/composio" install --help | grep -q -- '--shell'; then
327
echo 'expected the pinned CLI to predate install --shell' >&2
328
exit 1
329
fi
330
+test "$(grep -Fc '# Composio CLI' "$HOME/.${config.shell}rc")" = 1
331
curl -fsSL "$INSTALL_BASE_URL/install/${config.shell}" | sh -s -- "$E2E_VERSION"
229
-test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1
230
-test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
231
-zsh -ilc 'composio --version'
332
+test "$(grep -Fc '# Composio CLI' "$HOME/.${config.shell}rc")" = 1
333
+test "$(${config.shell} -ilc 'command -v composio')" = "$HOME/.local/bin/composio"
334
+${config.shell} -ilc 'composio --version'
335
+`);
336
+ assertSuccess(result);
337
+ },
338
+ timeout
339
+ );
340
+
341
+ it(
342
+ 'persists the resolved absolute bin directory through inline setup',
343
+ async () => {
344
+ // A relative COMPOSIO_BIN_DIR must never be persisted raw: the login
345
+ // shell check runs from / so only an absolute PATH entry can resolve.
346
+ const result = await run(`
347
+set -eu
348
+curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} COMPOSIO_BIN_DIR=.composio-bin sh -s -- "$E2E_VERSION"
349
+test -x "$HOME/.composio/composio"
350
+test -x "$HOME/.composio-bin/composio"
351
+test "$(grep -Fc '# Composio CLI' "$HOME/.${config.shell}rc")" = 1
352
+test "$(cd / && ${config.shell} -ilc 'command -v composio')" = "$HOME/.composio-bin/composio"
353
+(cd / && ${config.shell} -ilc 'composio --version')
354
+`);
355
+ assertSuccess(result);
356
+ },
357
+ timeout
358
+ );
359
+
360
+ it(
361
+ 'keeps the pinned install successful when inline setup cannot write the startup file',
362
+ async () => {
363
+ // Contract: binary installed, exit 0, warning, trusted absolute
364
+ // recovery command on the verified installed executable.
365
+ const result = await run(`
366
+set -eu
367
+mkdir "$HOME/.${config.shell}rc"
368
+combined=$(curl -fsSL "$INSTALL_BASE_URL/install" | SHELL=/bin/${config.shell} sh -s -- "$E2E_VERSION" 2>&1)
369
+test -x "$HOME/.composio/composio"
370
+test -L "$HOME/.local/bin/composio"
371
+printf '%s\n' "$combined" | grep -i 'warning'
372
+printf '%s\n' "$combined" | grep -F "$HOME/.composio/composio login"
373
`);
374
assertSuccess(result);
375
},