{"record":{"id":"19cdc421bb352a6c","repo":"warpdotdev/warp","slug":"could-not-determine-home-directory-19cdc4","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/gemini.rs","lineNumber":260,"sourceCode":"        )\n        .await\n    }\n\n    async fn cleanup(\n        &self,\n        _cleanup_disposition: HarnessCleanupDisposition,\n        _foreground: &ModelSpawner<AgentDriver>,\n    ) -> Result<()> {\n        Ok(())\n    }\n}\n\nfn prepare_gemini_environment_config(\n    working_dir: &Path,\n    system_prompt: Option<&str>,\n) -> Result<()> {\n    let home_dir =\n        dirs::home_dir().ok_or_else(|| anyhow::anyhow!(\"could not determine home directory\"))?;\n    let gemini_dir = home_dir.join(GEMINI_CONFIG_DIR);\n    prepare_gemini_settings(\n        &gemini_dir.join(GEMINI_SETTINGS_FILE_NAME),\n        system_prompt.is_some(),\n    )?;\n    prepare_gemini_trusted_folders(\n        &gemini_dir.join(GEMINI_TRUSTED_FOLDERS_FILE_NAME),\n        working_dir,\n    )?;\n    if let Some(prompt) = system_prompt {\n        let prompt_path = gemini_dir.join(GEMINI_SYSTEM_PROMPT_FILE_NAME);\n        std::fs::write(&prompt_path, prompt).with_context(|| {\n            format!(\n                \"Failed to write Gemini system prompt to {}\",\n                prompt_path.display()\n            )\n        })?;\n    }","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/harness/gemini.rs#L242-L278","documentation":"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.","triggerScenarios":"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.","commonSituations":"Docker/systemd/CI execution of the Gemini harness with HOME cleared; distroless images with synthetic users; sandboxed executors hiding the home path.","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."],"exampleFix":"# before\ndocker run warp-agent agent run --harness gemini …   # HOME unset → error\n\n# after\ndocker run -e HOME=/root warp-agent agent run --harness gemini …","handlingStrategy":"validation","validationCode":"anyhow::ensure!(dirs::home_dir().is_some(), \"set HOME before launching the gemini harness\");","typeGuard":"fn gemini_config_resolvable() -> bool {\n    dirs::home_dir().is_some()\n}","tryCatchPattern":"match prepare_gemini_environment_config(&working_dir, system_prompt.as_deref()) {\n    Err(err) if err.to_string().contains(\"could not determine home directory\") => {\n        std::env::set_var(\"HOME\", \"/tmp/warp-home\");\n        prepare_gemini_environment_config(&working_dir, system_prompt.as_deref())\n    }\n    rest => rest,\n}","preventionTips":["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."],"tags":["environment","home-directory","gemini","configuration","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}