warpdotdev/warp · error
could not determine home directory
Error message
could not determine home directory
What it means
Thrown by prepare_gemini_environment_config when dirs::home_dir() returns None, so the Gemini config directory (~/.gemini by GEMINI_CONFIG_DIR) cannot be built. The function needs it to write settings.json, trusted folders, and the optional system prompt (GEMINI_ALL_SYSTEM_PROMPTS/MEMORY) before launching the Gemini CLI.
Source
Thrown at app/src/ai/agent_sdk/driver/harness/gemini.rs:260
)
.await
}
async fn cleanup(
&self,
_cleanup_disposition: HarnessCleanupDisposition,
_foreground: &ModelSpawner<AgentDriver>,
) -> Result<()> {
Ok(())
}
}
fn prepare_gemini_environment_config(
working_dir: &Path,
system_prompt: Option<&str>,
) -> Result<()> {
let home_dir =
dirs::home_dir().ok_or_else(|| anyhow::anyhow!("could not determine home directory"))?;
let gemini_dir = home_dir.join(GEMINI_CONFIG_DIR);
prepare_gemini_settings(
&gemini_dir.join(GEMINI_SETTINGS_FILE_NAME),
system_prompt.is_some(),
)?;
prepare_gemini_trusted_folders(
&gemini_dir.join(GEMINI_TRUSTED_FOLDERS_FILE_NAME),
working_dir,
)?;
if let Some(prompt) = system_prompt {
let prompt_path = gemini_dir.join(GEMINI_SYSTEM_PROMPT_FILE_NAME);
std::fs::write(&prompt_path, prompt).with_context(|| {
format!(
"Failed to write Gemini system prompt to {}",
prompt_path.display()
)
})?;
}View on GitHub (pinned to e72fd7aacb)
Solutions
- Set HOME (Unix) or USERPROFILE (Windows) to a writable directory in the agent's process environment.
- For containers, add -e HOME=/root or a passwd entry for the runtime user.
- Verify with printenv HOME before launching the Gemini-harness agent.
Example fix
# before docker run warp-agent agent run --harness gemini … # HOME unset → error # after docker run -e HOME=/root warp-agent agent run --harness gemini …
Defensive patterns
Strategy: validation
Validate before calling
anyhow::ensure!(dirs::home_dir().is_some(), "set HOME before launching the gemini harness");
Type guard
fn gemini_config_resolvable() -> bool {
dirs::home_dir().is_some()
} Try / catch
match prepare_gemini_environment_config(&working_dir, system_prompt.as_deref()) {
Err(err) if err.to_string().contains("could not determine home directory") => {
std::env::set_var("HOME", "/tmp/warp-home");
prepare_gemini_environment_config(&working_dir, system_prompt.as_deref())
}
rest => rest,
} Prevention
- Unlike Claude/Codex, the Gemini path has no env-var override — HOME (or USERPROFILE) must be set.
- Add -e HOME=/... to container runs of the Gemini harness.
- Include a home-dir preflight in any supervisor spawning third-party CLI harnesses.
When it happens
Trigger: Preparing a Gemini-harness agent run in an environment where no home directory can be resolved — unset HOME/USERPROFILE, getpwuid failure for the runtime UID, stripped container/CI/service environments. Unlike the Codex/Claude paths there is no env-var override here; only home is consulted.
Common situations: Docker/systemd/CI execution of the Gemini harness with HOME cleared; distroless images with synthetic users; sandboxed executors hiding the home path.
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/19cdc421bb352a6c.
Report an issue: GitHub.