{"record":{"id":"cbc2c419580d0492","repo":"BoundaryML/baml","slug":"found-none-of-openapi-generator-openapi-generator-cli-or-npx","errorCode":null,"errorMessage":"Found none of openapi-generator, openapi-generator-cli, or npx in PATH","messagePattern":"Found none of openapi-generator, openapi-generator-cli, or npx in PATH","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/cli/init.rs","lineNumber":54,"sourceCode":"\nconst CLIENTS_BAML: &str = include_str!(\"initial_project/baml_src/clients.baml\");\nconst RESUME_BAML: &str = include_str!(\"initial_project/baml_src/resume.baml\");\n\n/// TODO: one problem with this impl - this requires all users to install openapi-generator the same way\nfn infer_openapi_command() -> Result<&'static str> {\n    if which(\"openapi-generator\").is_ok() {\n        return Ok(\"openapi-generator\");\n    }\n\n    if which(\"openapi-generator-cli\").is_ok() {\n        return Ok(\"openapi-generator-cli\");\n    }\n\n    if which(\"npx\").is_ok() {\n        return Ok(\"npx @openapitools/openapi-generator-cli\");\n    }\n\n    anyhow::bail!(\"Found none of openapi-generator, openapi-generator-cli, or npx in PATH\")\n}\n\n#[derive(Debug)]\nenum EditorType {\n    VSCode,\n    Cursor,\n    Unknown,\n}\n\nfn detect_editor() -> EditorType {\n    // Check for Cursor first since it might also set VSCode-like variables\n    if let Ok(cursor_trace_id) = env::var(\"CURSOR_TRACE_ID\") {\n        if !cursor_trace_id.is_empty() {\n            return EditorType::Cursor;\n        }\n    }\n\n    // Then check TERM_PROGRAM for both VSCode and Cursor","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/cli/init.rs#L36-L72","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Fresh Docker images or CI runners without Node.js, missing PATH entries for nvm/homebrew-installed tools, minimal Linux environments.","solutions":["Install Node.js (which provides npx) so `npx @openapitools/openapi-generator-cli` works.","Or install the generator directly: `npm install @openapitools/openapi-generator-cli -g` or brew install openapi-generator.","Verify with `which npx` / `which openapi-generator` that the tool is on PATH in the shell running baml init.","If you don't need OpenAPI output, check whether init has a flag to skip openapi generation."],"exampleFix":"// before: baml init fails\n// after (macOS/Linux)\nnpm install -g @openapitools/openapi-generator-cli\nbaml init  # now detects openapi-generator-cli","handlingStrategy":"validation","validationCode":"# before running baml init\ncommand -v openapi-generator || command -v openapi-generator-cli || command -v npx || { echo 'install openapi-generator or npx'; exit 1; }","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (String(e.message).includes('none of openapi-generator')) {\n    throw new Error('Install Node.js/npx or openapi-generator before baml init');\n  }\n}","preventionTips":["Bake Node.js/npx into dev container and CI images.","Document toolchain prerequisites (npx) in the project README.","Check PATH in the exact shell/CI environment that runs baml init."],"tags":["cli","path","openapi","missing-dependency"],"backgroundTag":"command-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}