{"record":{"id":"bfa9b2c3fb0a2860","repo":"warpdotdev/warp","slug":"could-not-determine-home-directory-bfa9b2","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_transcript.rs","lineNumber":100,"sourceCode":"    /// Codex session uuid passed to `codex resume <session_id>`. Matches `envelope.session_id`.\n    pub(crate) session_id: Uuid,\n    /// Envelope fetched from the server, written back to disk before launching codex.\n    pub(crate) envelope: CodexTranscriptEnvelope,\n}\n\n#[derive(Debug)]\npub(crate) struct CodexLocalContinuation {\n    pub(crate) command: String,\n    pub(crate) transcript_path: PathBuf,\n}\n\n/// Resolve the codex sessions root, honoring `$CODEX_HOME` then falling back to `~/.codex`.\npub(crate) fn codex_sessions_root() -> anyhow::Result<PathBuf> {\n    let home = if let Ok(dir) = std::env::var(CODEX_HOME_ENV) {\n        PathBuf::from(dir)\n    } else {\n        dirs::home_dir()\n            .ok_or_else(|| anyhow::anyhow!(\"could not determine home directory\"))?\n            .join(CODEX_HOME_DIRNAME)\n    };\n    Ok(home.join(CODEX_SESSIONS_SUBDIR))\n}\n\n/// Walk `<sessions_root>/YYYY/MM/DD/` looking for a `rollout-*-<session_id>.jsonl`.\n///\n/// Returns `None` if `sessions_root` doesn't exist yet or no matching file is found.\npub(crate) fn find_session_file(sessions_root: &Path, session_id: Uuid) -> Option<PathBuf> {\n    if !sessions_root.exists() {\n        return None;\n    }\n    let suffix = format!(\"-{session_id}.jsonl\");\n    for year_dir in read_subdirs(sessions_root) {\n        for month_dir in read_subdirs(&year_dir) {\n            for day_dir in read_subdirs(&month_dir) {\n                let entries = match fs::read_dir(&day_dir) {\n                    Ok(e) => e,","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/harness/codex_transcript.rs#L82-L118","documentation":"Thrown by codex_sessions_root() when CODEX_HOME is unset and dirs::home_dir() returns None, so the ~/.codex/sessions root cannot be formed. This root is where find_session_file walks YYYY/MM/DD/rollout-*-<session_id>.jsonl transcripts for Codex sessions.","triggerScenarios":"Resuming or hydrating a Codex conversation (locating its rollout transcript by session id) in a process with no CODEX_HOME and no home directory. Note: unlike codex_config_dir, this branch reads CODEX_HOME without checking for an empty string, so CODEX_HOME=\"\" also falls through to the home lookup and fails.","commonSituations":"Container/CI/sandbox runs of the Codex harness with HOME stripped; service managers that clear the environment; images with synthetic UIDs lacking passwd entries.","solutions":["Set CODEX_HOME to the directory containing the sessions tree so the root resolves deterministically.","Otherwise set HOME/USERPROFILE to a writable path.","When transcripts must survive restarts, point CODEX_HOME at a persistent volume."],"exampleFix":"# before\nwarp agent resume --harness codex <session>   # no CODEX_HOME, no HOME\n\n# after\nexport CODEX_HOME=/var/lib/warp/codex\nwarp agent resume --harness codex <session>","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 resolving codex transcripts\");\n}","typeGuard":"fn codex_sessions_locatable() -> bool {\n    std::env::var(\"CODEX_HOME\").map(|d| !d.is_empty()).unwrap_or(false) || dirs::home_dir().is_some()\n}","tryCatchPattern":"match codex_sessions_root() {\n    Err(err) if err.to_string().contains(\"could not determine home directory\") => {\n        // treat as 'no local transcripts', degrade to starting a new session\n        Ok(None)\n    }\n    rest => rest.map(Some),\n}","preventionTips":["Point CODEX_HOME at a persistent volume so session transcripts survive restarts.","Keep HOME defined in the process that resumes Codex sessions.","Remember an empty CODEX_HOME string is not honored here — set a real path."],"tags":["environment","home-directory","codex","transcripts","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}