Shell commands include workdir in command string

Resolved 💬 5 comments Opened Dec 9, 2025 by andjohnsonj5 Closed Mar 29, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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?

  1. Use the Codex CLI to run a shell command with a workdir set (e.g., rg -n worktree in /root/code/codex).
  2. 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.

View original on GitHub ↗

5 Comments

github-actions[bot] contributor · 8 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #7760

Powered by Codex Action

andjohnsonj5 · 8 months ago

@bolinfest

andjohnsonj5 · 8 months ago

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\"}"]}
andjohnsonj5 · 8 months ago

@etraut-openai

etraut-openai contributor · 5 months ago

This bug report hasn't been upvoted or received any additional posts in four months. Closing.