warpdotdev/warp · error
could not determine home directory
Error message
could not determine home directory
What it means
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.
Source
Thrown at app/src/ai/agent_sdk/driver/harness/codex.rs:599
safe_info!(
safe: ("Published {published} WARP_SKILL_DIRS skill(s) to the Codex skill root"),
full: (
"Published {published} WARP_SKILL_DIRS skill(s) to Codex skill root {}",
skill_root.display()
)
);
}
}
fn codex_config_dir() -> Result<PathBuf> {
if let Ok(dir) = std::env::var(CODEX_HOME_ENV)
&& !dir.is_empty()
{
return Ok(PathBuf::from(dir));
}
dirs::home_dir()
.map(|home| home.join(CODEX_CONFIG_DIR))
.ok_or_else(|| anyhow::anyhow!("could not determine home directory"))
}
fn write_codex_agents_override(codex_dir: &Path, system_prompt: &str) -> Result<()> {
fs::create_dir_all(codex_dir).with_context(|| {
format!(
"Failed to create Codex config dir at {}",
codex_dir.display()
)
})?;
// Note: this currently works because we are only doing this for cloud agents; if we enable
// this for local runs we'll want to make sure we don't clobber any existing file overrides.
let prompt_path = codex_dir.join(CODEX_AGENTS_OVERRIDE_FILE_NAME);
fs::write(&prompt_path, system_prompt).with_context(|| {
format!(
"Failed to write Codex system prompt to {}",
prompt_path.display()
)View on GitHub (pinned to e72fd7aacb)
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.
Example fix
# before docker run warp-agent agent run --harness codex … # HOME unset # after docker run -e CODEX_HOME=/var/lib/warp/codex warp-agent agent run --harness codex …
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 launching the codex harness");
} Type guard
fn codex_config_resolvable() -> bool {
std::env::var("CODEX_HOME").map(|d| !d.is_empty()).unwrap_or(false) || dirs::home_dir().is_some()
} Try / catch
match codex_config_dir() {
Err(err) if err.to_string().contains("could not determine home directory") => {
std::env::set_var("CODEX_HOME", "/tmp/warp-codex");
codex_config_dir()
}
rest => rest,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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/5158afc15471fd98.
Report an issue: GitHub.