Support remote `--cd` for `codex --remote` command

Resolved 💬 4 comments Opened Mar 28, 2026 by AdithyanI Closed Apr 3, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

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 --cd with 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?

  1. Start a remote app-server on a machine where a target project directory exists:
codex app-server --listen ws://<REMOTE_HOST>:<PORT>
  1. From another machine, verify the server is reachable:
curl -fsS http://<REMOTE_HOST>:<PORT>/readyz >/dev/null && echo ready
  1. 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'
  1. Observe the failure:
Error: No such file or directory (os error 2)
  1. As a control, connect to the same app-server directly over websocket and send thread/start with the same cwd:
{
  "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:

View original on GitHub ↗

4 Comments

etraut-openai contributor · 5 months ago

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 --cd is 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.

AdithyanI · 5 months ago

@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/project is 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:

  • one remote app-server serving multiple repos, vs
  • one app-server per repo/process
simonbs · 4 months ago

I also expected the --cd to 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:

codex app-server --listen ws://127.0.0.1:3000

Then I tried:

  1. Running codex --remote ws://127.0.0.1:3000 from a different directory. Codex does not use the current working directory, but instead uses the app server’s directory.
  2. Running codex --remote ws://127.0.0.1:3000 --cd /some/path. Codex ignores the --cd value and still uses the app server’s directory.

It'd be great if we the Codex CLI can respect the --cd folder when used with app server.

etraut-openai contributor · 4 months ago

This will be included in the next release!