Skip to content

Shell-style commands return empty output in Codex CLI runner #7317

Description

@gabrielecirulli

What version of the VS Code extension are you using?

0.4.46

What subscription do you have?

Plus

Which IDE are you using?

Visual Studio Code with Codex extension (Version: 1.106.3 Commit: bf9252a2fb45be6893dd8870c0bf37e2e1766d61)

What platform is your computer?

macOS (Darwin 25.0.0 arm64 arm)

What issue are you seeing?

Commands that include shell constructs (cd, &&, pipes) executed via the Codex runner return empty output or mis-parse arguments even though they exit with code 0, making builds/scripts appear broken.

What steps can reproduce the bug?

Minimal repro:

  1. mkdir demo && cd demo
  2. mkdir -p apps/frontend packages
  3. touch apps/frontend/placeholder.txt packages/readme.txt
  4. Open VS Code, install/enable the Codex extension. (code .)
  5. In VS Code, open the repo root (.) as the workspace so Codex starts in that directory.

With Codex ready, issue the following task:

Run these commands (VERBATIM, NO CHANGES) from the workspace root via the Codex runner:
A) `cd apps/frontend && ls`
B) `cd apps/frontend && echo test`
C) `cd /tmp && ls`
D) `ls /tmp | head`

Expected: normal stdout for each command.

Observed: A–C exit 0 with empty stdout; D treats "| head" as literal args and exits 1.

Workarounds that do show output:
- bash -lc 'cd apps/frontend && pwd; ls'
- (in real projects) tool-specific cwd flags, e.g., pnpm -C apps/frontend --version

Once you have observed that commands that should result in some output do not in fact result in any, attempt the workarounds. Then write a report with your findings.

What is the expected behavior?

Shell operators should behave like a normal POSIX shell: change directory, run subsequent commands, and show stdout/stderr. If unsupported, the runner should fail loudly instead of succeeding with empty output.

Additional information

Here are the findings reported by Codex when running the repro steps above:

Findings

  • cd apps/frontend && ls: exit 0, empty stdout.
  • cd apps/frontend && echo test: exit 0, empty stdout.
  • cd /tmp && ls: exit 0, empty stdout.
  • ls /tmp | head: exit 1; | and head treated as literal args (ls: |: No such file or directory, ls: head: No such file or directory); /tmp listing still printed after errors.
  • Workaround bash -lc 'cd apps/frontend && pwd; ls': exit 0; printed /Users/mars/work/2048/tmp-repro/apps/frontend and placeholder.txt.
  • Workaround pnpm -C apps/frontend --version: exit 0; printed 10.11.0.

Inference

  • Runner executes command strings without a shell, so shell features (cd, &&, pipes) aren’t interpreted and become literal argv tokens.
  • Wrapping the command in bash -lc '...' or using tool-specific cwd flags restores expected behavior.

Suggested next steps

  1. If shell semantics are desired by default, run commands via /bin/bash -lc "<user string>" (or equivalent) or document that users must wrap commands.
  2. Alternatively, forbid shell metacharacters and require explicit bash -lc when needed; warn when such tokens are detected.

Workspace: monorepo with apps/frontend and packages/*.
sandbox_mode: workspace-write; network: restricted.
Impact: routine subpackage scripts (build/lint) appear broken because output is suppressed unless using -C or bash -lc workarounds.

Full execution log:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingextensionIssues related to the VS Code extensiontool-callsIssues related to tool calling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions