@devries-cameron20 / composio Mirror · read-only / commits / c8a190b17
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 22, 04:30 UTC

fix(cli): align bash rc file selection with install.sh fallback

The install command now checks .bashrc then .bash_profile for the bash shell, picking the first existing file (or defaulting to .bashrc). This matches the install.sh fallback behavior and prevents the two paths from writing to different files.

jkomyno committed Mar 9, 2026 at 16:12 UTC c8a190b1739075b395a25326ffcfc6373f59640a
1 file changed +28 -7
ts/packages/cli/src/commands/install.cmd.ts
+28 -7
@@ -50,17 +50,37 @@ const detectShell = (): Shell | undefined => {
50 return undefined;
51 };
52
53 -const rcFileForShell = (shell: Shell, homedir: string): string => {
53 +/**
54 + * Return candidate rc file paths for a shell, ordered by preference.
55 + * For bash this mirrors the install.sh fallback: .bashrc then .bash_profile.
56 + */
57 +const rcFileCandidates = (shell: Shell, homedir: string): string[] => {
58 switch (shell) {
59 case 'zsh':
56 - return path.join(homedir, '.zshrc');
60 + return [path.join(homedir, '.zshrc')];
61 case 'bash':
58 - return path.join(homedir, '.bashrc');
62 + return [path.join(homedir, '.bashrc'), path.join(homedir, '.bash_profile')];
63 case 'fish':
60 - return path.join(homedir, '.config', 'fish', 'config.fish');
64 + return [path.join(homedir, '.config', 'fish', 'config.fish')];
65 }
66 };
67
68 +/**
69 + * Pick the first existing candidate, or fall back to the first candidate
70 + * (which will be created).
71 + */
72 +const resolveRcFile = (
73 + candidates: string[],
74 + fs: FileSystem.FileSystem
75 +): Effect.Effect<string, PlatformError> =>
76 + Effect.gen(function* () {
77 + for (const candidate of candidates) {
78 + const exists = yield* fs.exists(candidate);
79 + if (exists) return candidate;
80 + }
81 + return candidates[0]!;
82 + });
83 +
84 const pathBlockForShell = (shell: Shell, installDir: string): string => {
85 switch (shell) {
86 case 'fish':
@@ -80,12 +100,12 @@ const pathBlockForShell = (shell: Shell, installDir: string): string => {
100
101 const buildShellConfig = (
102 shell: Shell,
83 - homedir: string,
103 + rcFile: string,
104 installDir: string,
105 completionScript: string | undefined
106 ): ShellConfig => ({
107 shell,
88 - rcFile: rcFileForShell(shell, homedir),
108 + rcFile,
109 pathBlock: pathBlockForShell(shell, installDir),
110 completionBlock: completionScript ? `${COMPLETIONS_MARKER}\n${completionScript}` : undefined,
111 });
@@ -148,7 +168,8 @@ export const installShellIntegration = (params: {
168 completionScript = lines.length > 0 ? Arr.join(lines, '\n') : undefined;
169 }
170
151 - const config = buildShellConfig(shell, os.homedir, installDir, completionScript);
171 + const rcFile = yield* resolveRcFile(rcFileCandidates(shell, os.homedir), fs);
172 + const config = buildShellConfig(shell, rcFile, installDir, completionScript);
173
174 // Read existing rc file (or empty if it doesn't exist yet)
175 const rcPath = config.rcFile;