Skip to content

Fallback to available shell when run_terminal_command shell is missing#11131

Open
siewcapital wants to merge 1 commit intocontinuedev:mainfrom
Siew-s-Capital:fix/devcontainer-shell-fallback-11129
Open

Fallback to available shell when run_terminal_command shell is missing#11131
siewcapital wants to merge 1 commit intocontinuedev:mainfrom
Siew-s-Capital:fix/devcontainer-shell-fallback-11129

Conversation

@siewcapital
Copy link

@siewcapital siewcapital commented Mar 6, 2026

Summary

  • make the terminal tool choose the first available Unix shell from SHELL, /bin/bash, /bin/sh, and /bin/ash
  • avoid hard-failing when SHELL points to a missing path or /bin/bash is not installed
  • add a regression test that verifies command execution still succeeds when SHELL is invalid

Why

In remote/devcontainer setups, some environments do not expose the expected shell path. Falling back to an available shell prevents spawn ... ENOENT failures and keeps terminal tooling usable.

Closes #11129


Summary by cubic

Gracefully fall back to an available Unix shell in runTerminalCommand when SHELL is invalid or /bin/bash is missing, preventing spawn ENOENT errors in remote/devcontainer environments. Fixes #11129.

  • Bug Fixes
    • Select the first available shell from $SHELL, /bin/bash, /bin/sh, or /bin/ash (non-absolute shells are resolved via PATH).
    • Added a regression test to verify command execution succeeds when SHELL points to a missing path.

Written for commit e93cef3. Summary will update on new commits.

@siewcapital siewcapital requested a review from a team as a code owner March 6, 2026 17:05
@siewcapital siewcapital requested review from RomneyDa and removed request for a team March 6, 2026 17:05
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="core/tools/implementations/runTerminalCommand.vitest.ts">

<violation number="1" location="core/tools/implementations/runTerminalCommand.vitest.ts:162">
P1: Environment variable cleanup may leak SHELL state - assigning undefined to process.env creates string 'undefined'</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

expect(result[0].status).toBe("Command completed");
expect(result[0].content).toContain("fallback shell works");
} finally {
process.env.SHELL = originalShell;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Environment variable cleanup may leak SHELL state - assigning undefined to process.env creates string 'undefined'

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At core/tools/implementations/runTerminalCommand.vitest.ts, line 162:

<comment>Environment variable cleanup may leak SHELL state - assigning undefined to process.env creates string 'undefined'</comment>

<file context>
@@ -142,6 +142,27 @@ describe("runTerminalCommandImpl", () => {
+      expect(result[0].status).toBe("Command completed");
+      expect(result[0].content).toContain("fallback shell works");
+    } finally {
+      process.env.SHELL = originalShell;
+    }
+  });
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-merge size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Terminal tool fails in devcontainer with "spawn /bin/bash ENOENT"

1 participant