{"record":{"id":"4d30955c3b17eca3","repo":"warpdotdev/warp","slug":"could-not-determine-home-directory-4d3095","errorCode":null,"errorMessage":"could not determine home directory","messagePattern":"could not determine home directory","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/driver/harness/claude_code.rs","lineNumber":673,"sourceCode":"            full: (\n                \"Published {published} WARP_SKILL_DIRS skill(s) to Claude Code skill root {}\",\n                skill_root.display()\n            )\n        );\n    }\n}\n\n// This function is used specifically for determining where to land `.claude.json`.\nfn claude_global_config_path() -> Result<PathBuf> {\n    if let Ok(dir) = std::env::var(\"CLAUDE_CONFIG_DIR\")\n        && !dir.is_empty()\n    {\n        return Ok(PathBuf::from(dir).join(CLAUDE_JSON_FILE_NAME));\n    }\n\n    home_dir_for_claude_config()\n        .map(|home| home.join(CLAUDE_JSON_FILE_NAME))\n        .ok_or_else(|| anyhow::anyhow!(\"could not determine home directory\"))\n}\n\nfn prepare_claude_config(\n    claude_json_path: &Path,\n    working_dir: &Path,\n    api_key_suffix: Option<&str>,\n) -> Result<()> {\n    let mut claude_config: ClaudeConfig = read_json_file_or_default(claude_json_path)?;\n    claude_config.has_completed_onboarding = true;\n    claude_config.lsp_recommendation_disabled = true;\n    claude_config\n        .projects\n        .entry(working_dir.to_string_lossy().into_owned())\n        .or_default()\n        .has_trust_dialog_accepted = true;\n    if let Some(suffix) = api_key_suffix {\n        let responses = claude_config\n            .custom_api_key_responses","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/harness/claude_code.rs#L655-L691","documentation":"Thrown by claude_global_config_path() when CLAUDE_CONFIG_DIR is unset (or empty) and home_dir_for_claude_config() returns None, leaving nowhere to place/read .claude.json before launching the Claude Code CLI. The prepare_claude_config step (onboarding flags, project settings) therefore cannot run.","triggerScenarios":"Launching a Claude-harness agent with neither CLAUDE_CONFIG_DIR nor a resolvable home directory (dirs::home_dir() None and, outside tests, the HOME fallback unused) — unset HOME on Unix, unset USERPROFILE on Windows, or a user with no passwd entry.","commonSituations":"Containerized/CI runs of the Claude harness without HOME; systemd/docker/launchd environments that strip HOME; running as a synthetic UID; restricting sandboxes that hide the home path.","solutions":["Set CLAUDE_CONFIG_DIR to a writable directory (e.g. /state/claude) in the agent's environment — it takes priority and bypasses home lookup entirely.","Otherwise set HOME (Unix) / USERPROFILE (Windows) to a writable path.","Verify with: printenv CLAUDE_CONFIG_DIR HOME before launching the agent."],"exampleFix":"# before\nwarp agent run --harness claude …  # no CLAUDE_CONFIG_DIR, no HOME\n\n# after\nexport CLAUDE_CONFIG_DIR=/var/lib/warp/claude\nwarp agent run --harness claude …","handlingStrategy":"validation","validationCode":"if std::env::var(\"CLAUDE_CONFIG_DIR\").map_or(true, |d| d.is_empty())\n    && dirs::home_dir().is_none()\n{\n    anyhow::bail!(\"set CLAUDE_CONFIG_DIR or HOME before launching the claude harness\");\n}","typeGuard":"fn claude_config_resolvable() -> bool {\n    std::env::var(\"CLAUDE_CONFIG_DIR\").map(|d| !d.is_empty()).unwrap_or(false) || dirs::home_dir().is_some()\n}","tryCatchPattern":"match claude_global_config_path() {\n    Err(err) if err.to_string().contains(\"could not determine home directory\") => {\n        set_fallback_env_home()?; // set CLAUDE_CONFIG_DIR to a temp dir and retry\n        claude_global_config_path()\n    }\n    rest => rest,\n}","preventionTips":["Set CLAUDE_CONFIG_DIR in containerized/CI Claude-harness runs — it sidesteps home lookup entirely.","Ensure HOME/USERPROFILE is present in service environments.","Add an env preflight check before launching third-party CLI harnesses."],"tags":["environment","home-directory","claude-code","configuration","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}