BoundaryML/baml · error

Found none of openapi-generator, openapi-generator-cli, or n

Error message

Found none of openapi-generator, openapi-generator-cli, or npx in PATH

What it means

`baml-cli init` can generate an OpenAPI spec, which requires the openapi-generator tool. infer_openapi_command probes PATH for `openapi-generator`, `openapi-generator-cli`, then `npx`; if none exists it bails with this message. It means the environment lacks any way to invoke OpenAPI generator.

Source

Thrown at engine/baml-runtime/src/cli/init.rs:54

const CLIENTS_BAML: &str = include_str!("initial_project/baml_src/clients.baml");
const RESUME_BAML: &str = include_str!("initial_project/baml_src/resume.baml");

/// TODO: one problem with this impl - this requires all users to install openapi-generator the same way
fn infer_openapi_command() -> Result<&'static str> {
    if which("openapi-generator").is_ok() {
        return Ok("openapi-generator");
    }

    if which("openapi-generator-cli").is_ok() {
        return Ok("openapi-generator-cli");
    }

    if which("npx").is_ok() {
        return Ok("npx @openapitools/openapi-generator-cli");
    }

    anyhow::bail!("Found none of openapi-generator, openapi-generator-cli, or npx in PATH")
}

#[derive(Debug)]
enum EditorType {
    VSCode,
    Cursor,
    Unknown,
}

fn detect_editor() -> EditorType {
    // Check for Cursor first since it might also set VSCode-like variables
    if let Ok(cursor_trace_id) = env::var("CURSOR_TRACE_ID") {
        if !cursor_trace_id.is_empty() {
            return EditorType::Cursor;
        }
    }

    // Then check TERM_PROGRAM for both VSCode and Cursor

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Install Node.js (which provides npx) so `npx @openapitools/openapi-generator-cli` works.
  2. Or install the generator directly: `npm install @openapitools/openapi-generator-cli -g` or brew install openapi-generator.
  3. Verify with `which npx` / `which openapi-generator` that the tool is on PATH in the shell running baml init.
  4. If you don't need OpenAPI output, check whether init has a flag to skip openapi generation.

Example fix

// before: baml init fails
// after (macOS/Linux)
npm install -g @openapitools/openapi-generator-cli
baml init  # now detects openapi-generator-cli
Defensive patterns

Strategy: validation

Validate before calling

# before running baml init
command -v openapi-generator || command -v openapi-generator-cli || command -v npx || { echo 'install openapi-generator or npx'; exit 1; }

Try / catch

catch (e) {
  if (String(e.message).includes('none of openapi-generator')) {
    throw new Error('Install Node.js/npx or openapi-generator before baml init');
  }
}

Prevention

When it happens

Trigger: Running `baml init` (or the init command flow that requests OpenAPI generation) on a machine where none of openapi-generator, openapi-generator-cli, or npx are installed/on PATH.

Common situations: Fresh Docker images or CI runners without Node.js, missing PATH entries for nvm/homebrew-installed tools, minimal Linux environments.

Related errors


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