app-server rejects every turn with "invalid cwd" once the daemon's own working directory is deleted, even when the request cwd is absolute
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- backend-api-design
Línea de trabajo
Empieza leyendo codex-rs/utils/absolute-path/src/lib.rs cerca de relative_to_current_dir; después, comprueba quién lo llama en codex-rs/app-server/src/request_processors.rs y los puntos de llamada de turn y resume mencionados en el issue. Se considera terminado cuando un cwd absoluto de la solicitud se resuelve aunque se haya eliminado el propio directorio de trabajo del daemon, mientras que las rutas relativas siguen resolviéndose respecto al directorio actual.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
The shared app-server daemon starts with the working directory of the first codex invocation that spawns it. If that directory is later deleted (a removed git worktree, for example), every new turn/start on that daemon fails:
turn/start failed: invalid cwd: No such file or directory (os error 2) (code -32600)
This happens even though the turn's own cwd is an absolute path to a directory that exists. Every TUI attached to the daemon is affected until the daemon restarts. codex resume <thread> --no-daemon works around it for one session.
Why
resolve_request_cwd (codex-rs/app-server/src/request_processors.rs:629, rust-v0.160.0) resolves the request cwd with AbsolutePathBuf::relative_to_current_dir:
fn resolve_request_cwd(cwd: Option<PathBuf>) -> Result<Option<AbsolutePathBuf>, JSONRPCErrorError> {
cwd.map(|cwd| {
AbsolutePathBuf::relative_to_current_dir(path_utils::normalize_for_native_workdir(cwd))
.map_err(|err| invalid_request(format!("invalid cwd: {err}")))
})
.transpose()
}
relative_to_current_dir (codex-rs/utils/absolute-path/src/lib.rs:87) calls std::env::current_dir()? unconditionally, before it looks at whether path is already absolute:
pub fn relative_to_current_dir<P: AsRef<Path>>(path: P) -> std::io::Result<Self> {
Ok(Self::resolve_path_against_base(
path,
std::env::current_dir()?,
))
}
On Linux, getcwd fails with ENOENT when the process's cwd has been unlinked. So an absolute request path is rejected because of the daemon's own cwd, which the path does not depend on. The same call is used for turn/start (turn_processor.rs:621, :928) and thread resume (thread_processor.rs:3877).
Reproduce
- With no daemon running (
codex app-server daemon stop), runmkdir /tmp/x && cd /tmp/x && codex. This starts the daemon with cwd/tmp/x. Exit the TUI. rm -rf /tmp/xcd ~/some/repo && codex, then send any prompt. The turn fails withinvalid cwd.
Expected
An absolute request cwd resolves without consulting the process cwd. Only a relative request cwd needs current_dir(), and its error could say that the daemon's working directory no longer exists.
Possible fix: in relative_to_current_dir, return from_absolute_path(path) when path.is_absolute(), and call current_dir() only for relative input.
Related
The managed daemon and its updater both inherit the spawning terminal's cwd (codex app-server daemon start, and Daemon::stop leaves daemon-updater.pid running). So after stop + start, the next update recreates the daemon in the deleted directory again; only daemon bootstrap replaces both processes. Starting the managed daemon from a stable directory (for example $CODEX_HOME) regardless of the caller's cwd would remove the whole class.
Environment: codex-cli 0.160.0 (npm, linux-x64 musl), Ubuntu, managed app-server daemon (codex app-server --listen unix:// --managed-daemon).
Related report: #41559 (a session whose own cwd was removed). This issue is a different trigger: the request cwd exists and is absolute, and only the daemon process's cwd is gone.
- Lenguaje dominante
- Rust
- Estrellas
- 127k
- Forks
- 19.9k
- Merge medio
- 1 min
- PR fusionados (30 d)
- 994
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openai/codex
-
[macOS Desktop] New sidebar hover navigation accidentally switches sections while reaching a chatAbiertoapp bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
bug skills
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug CLI config
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Shell installer: updating PATH replaces symlinked profiles and changes existing file permissionsAbiertobug CLI
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Git Bash on Windows: terminal enlarge/shrink breaks chat input and previous conversation scrollingAbiertobug CLI TUI windows-os
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
Todos los issues de openai/codex
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
wardian-app/Wardian#1603 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
peteonrails/voxtype#844 ·
Los mantenedores suelen responder en 1 día
-
feature
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
uwuclxdy/clauth#107 · 1 comentario ·
Los mantenedores suelen responder en 4 días