BoundaryML/baml · error

could not find packaged playground assets. For local debuggi

Error message

could not find packaged playground assets. For local debugging, run `pnpm --filter app-vscode-webview dev -- --host 127.0.0.1 --port 4000` and set `BAML_PLAYGROUND_DEV_PORT=4000`, or set `BAML_PLAYGROUND_DIR` to a built app-vscode-webview/dist directory.

What it means

resolve_playground_assets locates the web UI assets (app-vscode-webview/dist) bundled with the CLI. When discover_playground_dir() finds nothing packaged or configured, it bails with instructions for local debugging. Without these assets the playground cannot serve its frontend.

Source

Thrown at baml_language/crates/baml_cli/src/playground_command.rs:140

    let root = project.root().to_path_buf();
    if project.files.is_empty() {
        anyhow::bail!("no `.baml` files found in {}", root.display());
    }
    Ok(vec![root])
}

fn resolve_playground_assets() -> Result<Option<PathBuf>> {
    if std::env::var_os("BAML_PLAYGROUND_DEV_PORT").is_some()
        || std::env::var_os("BAML_PLAYGROUND_DIR").is_some()
    {
        return Ok(None);
    }

    if let Some(dir) = discover_playground_dir()? {
        return Ok(Some(dir));
    }

    anyhow::bail!(
        "could not find packaged playground assets. For local debugging, run \
         `pnpm --filter app-vscode-webview dev -- --host 127.0.0.1 --port 4000` \
         and set `BAML_PLAYGROUND_DEV_PORT=4000`, or set `BAML_PLAYGROUND_DIR` \
         to a built app-vscode-webview/dist directory."
    );
}

fn discover_playground_dir() -> Result<Option<PathBuf>> {
    let exe = std::env::current_exe().context("could not resolve current executable")?;
    let Some(bin_dir) = exe.parent() else {
        return Ok(None);
    };

    Ok(playground_dir_candidates(bin_dir)
        .into_iter()
        .find(|path| is_playground_dir(path)))
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Set BAML_PLAYGROUND_DIR to a built app-vscode-webview/dist directory.
  2. For local debugging: run `pnpm --filter app-vscode-webview dev -- --host 127.0.0.1 --port 4000` and set BAML_PLAYGROUND_DEV_PORT=4000.
  3. Install a packaged release of the BAML CLI that ships playground assets.
  4. Verify the dist directory exists (build it with pnpm install && pnpm build in the webview workspace).

Example fix

// before
BAML_PLAYGROUND_DIR=./nonexistent baml playground

// after
pnpm --filter app-vscode-webview dev -- --host 127.0.0.1 --port 4000
export BAML_PLAYGROUND_DEV_PORT=4000
baml playground
Defensive patterns

Strategy: fallback

Validate before calling

# shell: pick assets location up front
if [ -z "$BAML_PLAYGROUND_DIR" ] && [ ! -d "$REPO/app-vscode-webview/dist" ]; then
  echo 'Build webview or set BAML_PLAYGROUND_DIR'; exit 1
fi

Prevention

When it happens

Trigger: Running `baml playground` when: no packaged assets directory exists next to the binary, BAML_PLAYGROUND_DEV_PORT is unset, and BAML_PLAYGROUND_DIR is unset or points to a non-existent/non-built directory — i.e. discover_playground_dir() returns None.

Common situations: Running a CLI built from a source checkout without building the webview frontend first; a release build stripped of packaged assets; BAML_PLAYGROUND_DIR pointing to the wrong path or an unbuilt repo; typo'd env var.

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/033c0cfe3b52a122. Report an issue: GitHub.