warpdotdev/warp · error
could not determine home directory
Error message
could not determine home directory
What it means
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.
Source
Thrown at app/src/ai/agent_sdk/driver/harness/codex_transcript.rs:100
/// Codex session uuid passed to `codex resume <session_id>`. Matches `envelope.session_id`.
pub(crate) session_id: Uuid,
/// Envelope fetched from the server, written back to disk before launching codex.
pub(crate) envelope: CodexTranscriptEnvelope,
}
#[derive(Debug)]
pub(crate) struct CodexLocalContinuation {
pub(crate) command: String,
pub(crate) transcript_path: PathBuf,
}
/// Resolve the codex sessions root, honoring `$CODEX_HOME` then falling back to `~/.codex`.
pub(crate) fn codex_sessions_root() -> anyhow::Result<PathBuf> {
let home = if let Ok(dir) = std::env::var(CODEX_HOME_ENV) {
PathBuf::from(dir)
} else {
dirs::home_dir()
.ok_or_else(|| anyhow::anyhow!("could not determine home directory"))?
.join(CODEX_HOME_DIRNAME)
};
Ok(home.join(CODEX_SESSIONS_SUBDIR))
}
/// Walk `<sessions_root>/YYYY/MM/DD/` looking for a `rollout-*-<session_id>.jsonl`.
///
/// Returns `None` if `sessions_root` doesn't exist yet or no matching file is found.
pub(crate) fn find_session_file(sessions_root: &Path, session_id: Uuid) -> Option<PathBuf> {
if !sessions_root.exists() {
return None;
}
let suffix = format!("-{session_id}.jsonl");
for year_dir in read_subdirs(sessions_root) {
for month_dir in read_subdirs(&year_dir) {
for day_dir in read_subdirs(&month_dir) {
let entries = match fs::read_dir(&day_dir) {
Ok(e) => e,View on GitHub (pinned to e72fd7aacb)
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.
Example fix
# before warp agent resume --harness codex <session> # no CODEX_HOME, no HOME # after export CODEX_HOME=/var/lib/warp/codex warp agent resume --harness codex <session>
Defensive patterns
Strategy: validation
Validate before calling
if std::env::var("CODEX_HOME").map_or(true, |d| d.is_empty()) && dirs::home_dir().is_none() {
anyhow::bail!("set CODEX_HOME or HOME before resolving codex transcripts");
} Type guard
fn codex_sessions_locatable() -> bool {
std::env::var("CODEX_HOME").map(|d| !d.is_empty()).unwrap_or(false) || dirs::home_dir().is_some()
} Try / catch
match codex_sessions_root() {
Err(err) if err.to_string().contains("could not determine home directory") => {
// treat as 'no local transcripts', degrade to starting a new session
Ok(None)
}
rest => rest.map(Some),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Container/CI/sandbox runs of the Codex harness with HOME stripped; service managers that clear the environment; images with synthetic UIDs lacking passwd entries.
Related errors
- could not determine home directory
- could not determine home directory
- Could not determine home directory
- could not determine home directory
- could not determine home directory
AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16).
Data as JSON: /api/errors/bfa9b2c3fb0a2860.
Report an issue: GitHub.