{"record":{"id":"5158afc15471fd98","repo":"warpdotdev/warp","slug":"could-not-determine-home-directory-5158af","errorCode":null,"errorMessage":"could not determine home directory","messagePattern":"could not determine home directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/driver/harness/codex.rs","lineNumber":599,"sourceCode":"        safe_info!(\n            safe: (\"Published {published} WARP_SKILL_DIRS skill(s) to the Codex skill root\"),\n            full: (\n                \"Published {published} WARP_SKILL_DIRS skill(s) to Codex skill root {}\",\n                skill_root.display()\n            )\n        );\n    }\n}\n\nfn codex_config_dir() -> Result<PathBuf> {\n    if let Ok(dir) = std::env::var(CODEX_HOME_ENV)\n        && !dir.is_empty()\n    {\n        return Ok(PathBuf::from(dir));\n    }\n    dirs::home_dir()\n        .map(|home| home.join(CODEX_CONFIG_DIR))\n        .ok_or_else(|| anyhow::anyhow!(\"could not determine home directory\"))\n}\n\nfn write_codex_agents_override(codex_dir: &Path, system_prompt: &str) -> Result<()> {\n    fs::create_dir_all(codex_dir).with_context(|| {\n        format!(\n            \"Failed to create Codex config dir at {}\",\n            codex_dir.display()\n        )\n    })?;\n\n    // Note: this currently works because we are only doing this for cloud agents; if we enable\n    // this for local runs we'll want to make sure we don't clobber any existing file overrides.\n    let prompt_path = codex_dir.join(CODEX_AGENTS_OVERRIDE_FILE_NAME);\n    fs::write(&prompt_path, system_prompt).with_context(|| {\n        format!(\n            \"Failed to write Codex system prompt to {}\",\n            prompt_path.display()\n        )","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/harness/codex.rs#L581-L617","documentation":"Thrown by codex_config_dir() when the CODEX_HOME env var is unset (or empty) and dirs::home_dir() returns None, leaving no ~/.codex base directory. The harness then cannot write Codex config (agents override, system prompt, auth) before launching the Codex CLI.","triggerScenarios":"Preparing a Codex-harness agent run with CODEX_HOME unset/empty and no resolvable home directory — unset HOME/USERPROFILE, no passwd entry for the UID, or a container/service environment that strips them.","commonSituations":"Dockerized or CI executions of the Codex harness without HOME; systemd units missing Environment=HOME; minimal images (distroless/scratch) where getpwuid cannot answer; environments where CODEX_HOME was expected to be injected but was not.","solutions":["Set CODEX_HOME to a writable directory in the agent's environment — it short-circuits the home lookup entirely.","Otherwise set HOME (Unix) or USERPROFILE (Windows) to a writable path.","Verify with printenv CODEX_HOME HOME before launching the Codex-harness agent."],"exampleFix":"# before\ndocker run warp-agent agent run --harness codex …   # HOME unset\n\n# after\ndocker run -e CODEX_HOME=/var/lib/warp/codex warp-agent agent run --harness codex …","handlingStrategy":"validation","validationCode":"if std::env::var(\"CODEX_HOME\").map_or(true, |d| d.is_empty()) && dirs::home_dir().is_none() {\n    anyhow::bail!(\"set CODEX_HOME or HOME before launching the codex harness\");\n}","typeGuard":"fn codex_config_resolvable() -> bool {\n    std::env::var(\"CODEX_HOME\").map(|d| !d.is_empty()).unwrap_or(false) || dirs::home_dir().is_some()\n}","tryCatchPattern":"match codex_config_dir() {\n    Err(err) if err.to_string().contains(\"could not determine home directory\") => {\n        std::env::set_var(\"CODEX_HOME\", \"/tmp/warp-codex\");\n        codex_config_dir()\n    }\n    rest => rest,\n}","preventionTips":["Set CODEX_HOME in containerized Codex-harness runs to bypass home lookup.","Ensure HOME/USERPROFILE is present in service/CI environments.","Include env preflight checks in deployment scripts for third-party harnesses."],"tags":["environment","home-directory","codex","configuration","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}