Shell commands include workdir in command string
What version of Codex is running?
codex-cli 0.65.0
What subscription do you have?
plus
Which model were you using?
gpt-5.1-codex
What platform is your computer?
Linux 6.12.43+deb13-amd64 x86_64 unknown
What issue are you seeing?
Shell commands are failing because the workdir metadata is appended to the command string instead of being passed as the working directory. The CLI emitted:
bash -lc "rg -n worktree","workdir":"/root/code/codex"}
The ,"workdir":"/root/code/codex"} fragment becomes part of the command text, so bash treats it as an argument and errors (e.g., bash: line 1: ,workdir:/root/code/codex}: No such file or directory).
What steps can reproduce the bug?
- Use the Codex CLI to run a shell command with a workdir set (e.g.,
rg -n worktreein/root/code/codex). - The CLI emits
bash -lc "<command>","workdir":"<path>"}and passes it to bash, which fails because the trailing workdir fragment is interpreted as part of the command string.
What is the expected behavior?
workdir should be used only to set the working directory for the spawned process, not appended to the shell command string or shown in the command text.
Additional information
- The current behavior both breaks otherwise-valid commands and unnecessarily exposes the workdir value in the command invocation.
- Observed repeatedly when running commands from the CLI.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #7760
Powered by Codex Action
@bolinfest
Below prompt can help reduce workdir mistakes:
-
Put only the command in the command field: The command to execute must appear only in the
"command"array (e.g.,["bash","-lc","rg -n worktree"]). Do not embed any JSON fragments or metadata inside the command string. -
Specify workdir separately:
"workdir"must be its own field (e.g.,"workdir": "/root/code/codex"). It is forbidden to append it inside the command text such as,"workdir":…. -
Follow the correct format:
- ✅
{"command":["bash","-lc","rg -n worktree"],"workdir":"/root/code/codex"} - ❌
{"command":["bash","-lc","rg -n worktree\",\"workdir\":\"/root/code/codex\"}"]}
- ✅
@etraut-openai
This bug report hasn't been upvoted or received any additional posts in four months. Closing.