Shell-style commands return empty output in Codex CLI runner
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;|andheadtreated as literal args (ls: |: No such file or directory,ls: head: No such file or directory);/tmplisting still printed after errors. - Workaroundbash -lc 'cd apps/frontend && pwd; ls': exit 0; printed/Users/mars/work/2048/tmp-repro/apps/frontendandplaceholder.txt. - Workaroundpnpm -C apps/frontend --version: exit 0; printed10.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 inbash -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 explicitbash -lcwhen 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:
<img width="557" height="1041" alt="Image" src="https://github.com/user-attachments/assets/9372e18a-4b2b-452b-91a3-d1e41b1a63b1" />
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Please note that I cannot reproduce the above when using Codex CLI from the terminal.
I would like to add a note about impact of this bug.
Quite often
codexonce knowing structure of project, tries to look for some patterns usingrg, so that it runs dozen times commands like:and so on until it figures out how to find it. That seems to be huge waste of tokens (and compute power, energy in big scale).
Also it can't detect failing tests (
cd $workdir '&&' npm run test). That adds developer frustration to equation - arguing that test are in fact failing and it is lying. Followed by hunting for root cause, suspecting sandbox issues etc.@d21d3q are you also only seeing this in VS Code, or in the CLI as well?
@gabrielecirulli what is your system default shell? can you try updating to a more recent version of the extension and seeing if the problem persists?
I encountered this problem when trying out another tool, and the root cause turned out to be the customizations in my ~/.bashrc. I redirect stdout and stderr in the .bashrc file, and that was causing all the output of the tool to be captured by that redirection. After I fixed that redirection code in .bashrc, the tool started receiving the stdout and stderr from the subcommands.
To verify if you have the same root cause, try renaming/moving the .bashrc file and see if the problem is still reproducible.
This bug report hasn't received any upvotes or additional posts in three months. Closing.