warpdotdev/warp · error · anyhow::Error

could not determine home directory

Error message

could not determine home directory

What it means

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.

Source

Thrown at app/src/ai/agent_sdk/driver/harness/claude_code.rs:673

            full: (
                "Published {published} WARP_SKILL_DIRS skill(s) to Claude Code skill root {}",
                skill_root.display()
            )
        );
    }
}

// This function is used specifically for determining where to land `.claude.json`.
fn claude_global_config_path() -> Result<PathBuf> {
    if let Ok(dir) = std::env::var("CLAUDE_CONFIG_DIR")
        && !dir.is_empty()
    {
        return Ok(PathBuf::from(dir).join(CLAUDE_JSON_FILE_NAME));
    }

    home_dir_for_claude_config()
        .map(|home| home.join(CLAUDE_JSON_FILE_NAME))
        .ok_or_else(|| anyhow::anyhow!("could not determine home directory"))
}

fn prepare_claude_config(
    claude_json_path: &Path,
    working_dir: &Path,
    api_key_suffix: Option<&str>,
) -> Result<()> {
    let mut claude_config: ClaudeConfig = read_json_file_or_default(claude_json_path)?;
    claude_config.has_completed_onboarding = true;
    claude_config.lsp_recommendation_disabled = true;
    claude_config
        .projects
        .entry(working_dir.to_string_lossy().into_owned())
        .or_default()
        .has_trust_dialog_accepted = true;
    if let Some(suffix) = api_key_suffix {
        let responses = claude_config
            .custom_api_key_responses

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. 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.
  2. Otherwise set HOME (Unix) / USERPROFILE (Windows) to a writable path.
  3. Verify with: printenv CLAUDE_CONFIG_DIR HOME before launching the agent.

Example fix

# before
warp agent run --harness claude …  # no CLAUDE_CONFIG_DIR, no HOME

# after
export CLAUDE_CONFIG_DIR=/var/lib/warp/claude
warp agent run --harness claude …
Defensive patterns

Strategy: validation

Validate before calling

if std::env::var("CLAUDE_CONFIG_DIR").map_or(true, |d| d.is_empty())
    && dirs::home_dir().is_none()
{
    anyhow::bail!("set CLAUDE_CONFIG_DIR or HOME before launching the claude harness");
}

Type guard

fn claude_config_resolvable() -> bool {
    std::env::var("CLAUDE_CONFIG_DIR").map(|d| !d.is_empty()).unwrap_or(false) || dirs::home_dir().is_some()
}

Try / catch

match claude_global_config_path() {
    Err(err) if err.to_string().contains("could not determine home directory") => {
        set_fallback_env_home()?; // set CLAUDE_CONFIG_DIR to a temp dir and retry
        claude_global_config_path()
    }
    rest => rest,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/4d30955c3b17eca3. Report an issue: GitHub.