BoundaryML/baml · error

Could not determine home directory

Error message

Could not determine home directory

What it means

get_playground_dist needs a directory under the user's home (~/.baml/playground) to cache the extracted web-panel dist. It calls dirs::home_dir() and errors when the OS yields no home directory. Without it, the server cannot locate or extract the playground static assets.

Solutions

  1. Set the HOME environment variable (Unix) or USERPROFILE (Windows) for the process running the playground server.
  2. If running under systemd/Docker, add Environment=HOME=/root or run as a user with a valid passwd home entry.
  3. Verify with: run the same command after `echo $HOME` prints a valid directory.

Example fix

// before (Dockerfile)
CMD ["./baml-playground-server"]
// after
ENV HOME=/root
CMD ["./baml-playground-server"]
Defensive patterns

Strategy: validation

Validate before calling

// shell check before starting the server
[ -n "$HOME" ] && [ -d "$HOME" ] || { echo 'HOME is not set'; exit 1; }

Prevention

When it happens

Trigger: Any request routed through playground_static_assets -> get_playground_dist when dirs::home_dir() returns None (e.g. no HOME env var on Unix, or unresolvable profile on Windows).

Common situations: Running the playground server in a container/systemd service with no HOME set; running as a system user with an unset home in /etc/passwd; stripped-down CI images where HOME is not exported.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/93081f91597a0a03. Report an issue: GitHub.

Appendix: source

Thrown at engine/playground-server/src/server.rs:192

        .ok_or_else(|| {
            anyhow::anyhow!(
                "No checksum asset named '{}' in release",
                checksum_asset_name
            )
        })?;
    let checksum_url = checksum_asset["browser_download_url"]
        .as_str()
        .ok_or_else(|| anyhow::anyhow!("No download URL for checksum asset"))?;

    tracing::info!(
        "Found assets - main: {}, checksum: {}",
        download_url,
        checksum_url
    );

    // Compute extraction directory using the provided version
    let home =
        dirs::home_dir().ok_or_else(|| anyhow::anyhow!("Could not determine home directory"))?;
    let extract_root: PathBuf = home
        .join(".baml/playground")
        .join(format!("web-panel-dist-{version}"));
    let dist_dir = extract_root.join("dist");

    // If already extracted, return the correct directory
    if dist_dir.exists() && dist_dir.read_dir()?.next().is_some() {
        tracing::info!("Web panel already extracted at: {}", dist_dir.display());
        return Ok(dist_dir.to_string_lossy().to_string());
    } else if extract_root.exists() {
        std::fs::remove_dir_all(&extract_root).with_context(|| {
            format!(
                "Failed to remove old extraction directory: {}",
                extract_root.display()
            )
        })?;
    }
    std::fs::create_dir_all(&extract_root).with_context(|| {

View on GitHub (pinned to bd85ce9dee)