Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.160.0 (npm, linux-x86_64)
What subscription do you have?
ChatGPT (sign-in with ChatGPT account)
Which model were you using?
n/a — the failure happens during TUI startup, before any turn starts.
What platform is your computer?
Linux x86_64, headless SSH server (TencentOS Server 4.4, kernel 5.4)
What terminal emulator and version are you using (if applicable)?
SSH session running inside herdr (a terminal workspace manager whose task panes run in per-task git worktrees). The terminal itself doesn't matter; herdr matters only because it removes a worktree when the task ends — which is exactly what deletes the daemon's startup directory below.
Codex doctor report
Excerpt (paths sanitized). Note that doctor reports the background server as healthy while it is broken — the control-socket probes it uses never reload config:
{
"app_server.status": {
"status": "ok",
"summary": "background server is running",
"details": {
"app-server version": "0.160.0",
"control socket": "/home/<user>/.codex/app-server-control/app-server-control.sock",
"mode": "ephemeral",
"status": "running"
}
},
"config.load": {
"status": "ok",
"summary": "config loaded",
"details": {
"CODEX_HOME": "/home/<user>/.codex",
"config.toml parse": "ok",
"cwd": "/home/<user>",
"feature flag overrides": "none"
}
}
}What issue are you seeing?
Every interactive codex start is blocked by the dialog "Cannot use the background server" with reason "Experimental feature request failed". "Restart with these settings" is disabled ("Restart cannot resolve this compatibility check."), so the only ways forward are "Run without daemon this time" or Cancel — and the next start hits the same dialog. This affects every session from any directory until the daemon is manually restarted.
Root cause: the auto-started managed daemon inherits the CWD of whichever terminal first launched it. When that directory is later deleted, every daemon RPC that reloads config without a cwd override fails with ENOENT. The TUI runs a daemon-feature compatibility check on every startup (request id tui-daemon-features, tui/src/daemon_startup.rs:145), which calls experimentalFeature/list; its handler reloads config strictly and turns the ENOENT into an internal error:
app-server/src/request_processors/catalog_processor.rs
experimental_feature_list_response (v0.160.0 :346)
→ self.load_latest_config(/*fallback_cwd*/ None) // :373
→ config load with no cwd override
→ AbsolutePathBuf::current_dir()? // core/src/config/mod.rs:1513 (v0.160.0; :1526 on current main)
→ ENOENT because the daemon cwd was deleted
→ .map_err(|err| internal_error(format!("failed to reload config: {err}"))) // :277
so the daemon answers:
{"error":{"code":-32603,"message":"failed to reload config: No such file or directory (os error 2)"}}tui/src/experimental_features.rs:46 maps that to "Experimental feature request failed", which daemon_recovery.rs renders as the blocking dialog (restart disabled because restart_features is None).
Evidence, all reproduced locally on 0.160.0:
- Daemon process (PPID 1, started the previous day):
$ readlink /proc/<pid>/cwd /home/<user>/.herdr/worktrees/<repo>/<branch> (deleted) $ tr '\0' ' ' < /proc/<pid>/cmdline /home/<user>/.codex/packages/app-server-daemon/releases/0.160.0-x86_64-unknown-linux-musl/bin/codex app-server --listen unix:// --managed-daemon - Direct JSON-RPC against the control socket (
$CODEX_HOME/app-server-control/app-server-control.sock, WebSocket upgrade over the Unix socket):initialize→ OK;experimentalFeature/list→ the-32603error above. - Controlled experiment with the same daemon binary: started in a temp dir,
experimentalFeature/listanswers normally with the full feature list (~154 entries); afterrm -rfof that dir the very same request immediately returns the-32603error. Nothing else changed — deleting the daemon's CWD alone is sufficient. codex doctorreports the background server healthy (excerpt above) while all of this is happening, because its probes never reload config.
What steps can reproduce the bug?
codex app-server daemon stop # start clean (or use a fresh CODEX_HOME)
mkdir /tmp/A && cd /tmp/A
codex # auto-starts the managed daemon with cwd=/tmp/A
# exit codex; the daemon persists (PPID 1)
cd ~ && rm -rf /tmp/A
codex # → "Cannot use the background server", every startReal-world trigger: the first codex session of the day runs inside a git worktree that is later cleaned up (task-per-worktree workflows, terminal workspace managers). Since the daemon's CWD is inherited from that first session, it is effectively guaranteed to be a disposable directory.
What is the expected behavior?
Any of these would resolve it — and the in-tree patterns already exist:
- The daemon should not depend on the lifetime of its startup directory (e.g.
chdirto$CODEX_HOMEor/at startup). - This RPC could pass a stable fallback cwd, or fall back to the startup config on reload failure. Both patterns are already in the 0.160.0 tree:
app-server/src/config_manager.rsload_default_config()builds with.fallback_cwd(Some(self.codex_home.clone()));request_processors/account_processor.rsload_latest_config()logs"failed to reload config, using startup config"and continues with the startup config.
- The
tui-daemon-featurescompatibility check could treat a config-reload failure as "daemon unhealthy — offer restart" instead of a dead-end dialog.
Additional information
- Same root-cause family as Auto-Started Daemon Returns Incorrect Session Directories After Its Startup Directory Is Deleted #48879 (auto-started daemon + deleted startup directory), where the fix short-circuits
relative_to_current_dirin theabsolute-pathcrate for absolute paths. That does not cover this path: the no-override branch still callscurrent_dir()directly (core/src/config/mod.rs:1513, identical on current main), andexperimentalFeature/listpassesfallback_cwd: None.catalog_processor.rsis byte-identical between v0.160.0 and current main, so as far as I can tell this path is still live on main. - Related: Codex can remove its own cwd which irrevocably breaks the session with Failed to start turn: turn/start failed in TUI: turn/start failed: invalid cwd: No such file or directory (os error 2) (code -32600) #41559 (deleted cwd breaks sessions; open), 0.157.0 background server compatibility check fails when workspace_dependencies is enabled #48160 (the same compatibility dialog misfiring on feature mismatches; open).
- Workaround:
codex app-server daemon stop, then start codex from a directory that won't be deleted (orcodex app-server daemon restartfrom a stable cwd).
Activity
Welith commentedon Oct 4, 2026
Independent confirmation on macOS ARM with the same failure mode.
Environment:
0.160.0, installed through npm0.160.026.4.0, arm64470The managed daemon had remained alive after its startup project directory was deleted.
lsof -a -p <daemon-pid> -d cwdstill showed that deleted project as the daemon's CWD, while a normal filesystem lookup for the path returnedENOENT.I connected directly to the daemon's Unix control socket, initialized with
experimentalApi: true, and sentexperimentalFeature/listwithlimit: 100. The literal response was:{ "error": { "code": -32603, "message": "failed to reload config: No such file or directory (os error 2)" }, "id": 2 }As a control, I started a fresh app-server from an existing directory using the same installed CLI version and the same user configuration, then sent the same request. The diagnostic output was:
{ "id": 2, "featureCount": 100, "nextCursor": "100" }This confirms the failure is tied to the long-lived daemon's deleted inherited CWD, rather than a CLI/app-server version mismatch or malformed user configuration. It also reproduces the same dead-end TUI dialog:
Restart with these settingsis disabled even though replacing the daemon from a valid CWD is the appropriate recovery.sghhhh commentedon Oct 5, 2026
Independent confirmation on macOS 27.0.1 / arm64, with the CLI installed through Homebrew. Both the CLI and the managed app-server are 0.160.0.
A normal
codexlaunch reproduces the blocking dialog withExperimental feature request failed. The managed daemon is still running, andlsof -a -p <daemon-pid> -d cwdshows its startup project directory, while a filesystem check confirms that directory no longer exists.daemon_auto_startis enabled.A controlled JSON-RPC experiment using
codex app-server --stdio, the same installed CLI binary, and the existing user configuration confirms that deleting the server's working directory alone is sufficient:experimentalApi: true.experimentalFeature/listwithparams: {}: success, 154 features,nextCursor: null.{ "error": { "code": -32603, "message": "failed to reload config: No such file or directory (os error 2)" }, "id": 3 }codex --no-daemonsuccessfully opens the TUI on this machine.This also supports starting the shared daemon from a stable service directory under
CODEX_HOME, with project working directories and project configuration supplied separately per session. Global configuration/feature discovery should remain usable after a startup project directory is removed.masmau commentedon Oct 5, 2026
I encountered the same problem on Linux x86_64 with codex-cli 0.160.0, installed via npm, running inside tmux 3.4.
Before applying the workaround:
codex app-server daemon versionreportedstatus: running,backend: pid, and CLI, managed Codex, and app-server versions all at0.160.0.codex doctor --summaryreported21 ok · 1 notes · 0 warn · 0 fail, includingapp-server running (ephemeral mode). The only note concerned rollout storage.I identified the managed daemon with:
pgrep -af 'codex.*app-server.*managed-daemon'Then checked its working directory:
The result ended in
(deleted).Restarting the daemon from my home directory resolved the problem:
This independently confirms the deleted daemon CWD symptom and that Doctor can report the background server as healthy while this problem is occurring.