Support remote `--cd` for `codex --remote` command
What issue are you seeing?
Human-readable setup:
- app-server is running on a remote Mac mini
- the
codex --remote ...client is running on a separate MacBook - the client can connect to the remote app-server normally
- the failure only happens when passing
--cdwith a path that exists on the remote machine but not on the local machine
codex --remote ... --cd <remote-path> fails with:
Error: No such file or directory (os error 2)
This happens even when the remote app-server is running and the same cwd is valid on the remote host.
I verified that the remote app-server itself accepts the exact same path over the websocket protocol via thread/start with cwd set, and returns that cwd in the response. That suggests the issue is in the stock CLI's --remote / --cd handling rather than app-server cwd support.
Environment:
- local client:
codex-cli 0.117.0 - remote server:
codex-cli 0.117.0 - local client machine: MacBook
- remote server machine: Mac mini
- local OS: macOS arm64
- remote OS: macOS arm64
- transport: websocket (
codex app-server --listen ws://<REMOTE_HOST>:<PORT>)
What steps can reproduce the bug?
- Start a remote app-server on a machine where a target project directory exists:
codex app-server --listen ws://<REMOTE_HOST>:<PORT>
- From another machine, verify the server is reachable:
curl -fsS http://<REMOTE_HOST>:<PORT>/readyz >/dev/null && echo ready
- Try to launch the TUI against that remote server with a remote-only working directory:
codex --remote ws://<REMOTE_HOST>:<PORT> --no-alt-screen --cd /path/on/remote/host/project 'say hello'
- Observe the failure:
Error: No such file or directory (os error 2)
- As a control, connect to the same app-server directly over websocket and send
thread/startwith the samecwd:
{
"method": "thread/start",
"id": 2,
"params": {
"model": "gpt-5.4",
"cwd": "/path/on/remote/host/project",
"approvalPolicy": "never"
}
}
The server accepts it and returns:
{
"accepted_cwd": "/path/on/remote/host/project",
"thread_cwd": "/path/on/remote/host/project"
}
What is the expected behavior?
If --remote is being used, I would expect --cd to be forwarded as the remote thread/session cwd without requiring that path to exist on the local machine.
At minimum, if remote-only --cd is not intended to be supported, it would be helpful for the CLI/docs to state that explicitly.
Additional information
This seems consistent with the CLI validating --cd locally before sending anything to the remote app-server.
Relevant docs that appear to support the underlying behavior:
- CLI
--cd: https://developers.openai.com/codex/cli/features/#tips-and-shortcuts - App-server
thread/startwithcwd: https://developers.openai.com/codex/app-server/#start-or-resume-a-thread - App-server lifecycle noting
turn/startcan overridecwd: https://developers.openai.com/codex/app-server/#lifecycle-overview
4 Comments
This isn't how it's currently designed to work, so I don't consider this a bug. But I think you're making a reasonable argument that the behavior should change such that
--cdis forwarded to the remote server. I've changed this from a bug report to an enhancement request, and we'll prioritize it based on upvotes.@etraut-openai Thanks, that makes sense.
In that case, could you clarify the intended current workflow for choosing the remote working directory when using the stock CLI with a remote app-server on a different machine?
Concretely, if
codex --remote --cd /path/on/remote/host/projectis not intended to work, what is the recommended way today to connect the client to a specific repo on the remote machine?I’m especially trying to understand the best supported setup for:
I also expected the
--cdto work with app server. I’m trying to use the Codex CLI with a running codex app-server, and I want to start sessions in different working directories depending on how I invoke the CLI.However, I too fiound that Codex always uses working directory where the app server was started, regardless of what I pass via the CLI.
I’m starting the app server like this:
Then I tried:
codex --remote ws://127.0.0.1:3000from a different directory. Codex does not use the current working directory, but instead uses the app server’s directory.odex --remote ws://127.0.0.1:3000 --cd /some/path. Codex ignores the--cdvalue and still uses the app server’s directory.It'd be great if we the Codex CLI can respect the
--cdfolder when used with app server.This will be included in the next release!