BoundaryML/baml · error

ErrNotSupportedPlatform

ErrNotSupportedPlatform

Error message

baml: platform not supported (only Linux and MacOS amd64/arm64)

What it means

ErrNotSupportedPlatform is returned when the current GOOS/GOARCH combination is not one of the supported targets (Linux and macOS on amd64/arm64). initializeBaml checks isSupportedPlatform() before anything else, and getTargetLibFilename rejects architectures with no prebuilt native library.

Solutions

  1. Run on a supported platform: linux/amd64, linux/arm64, darwin/amd64, or darwin/arm64
  2. For unsupported architectures, use Docker with platform emulation (docker run --platform linux/amd64) or Rosetta on Apple Silicon x86 images
  3. Check GOOS/GOARCH at startup and fail fast with a clear message instead of letting init fail opaquely
  4. If you truly need another target, build the BAML native library yourself for that triple and place it at the expected path

Example fix

// before
// go build on linux/riscv64
// after
GOOS=linux GOARCH=amd64 go build ./...  // or run under qemu/box64 emulation
Defensive patterns

Strategy: validation

Validate before calling

func bamlSupported() bool {
    switch runtime.GOOS {
    case "linux", "darwin":
        switch runtime.GOARCH {
        case "amd64", "arm64":
            return true
        }
    }
    return false
}

Try / catch

if !bamlSupported() {
    return fmt.Errorf("unsupported platform %s/%s for baml", runtime.GOOS, runtime.GOARCH)
}

Prevention

When it happens

Trigger: Running on GOOS/GOARCH like windows/386, freebsd/arm64, linux/riscv64, or darwin/386; or getTargetLibFilename receiving an unsupported goarch such as 386.

Common situations: Building on Windows (no native library target wired for it in the Go client's supported set), Raspberry Pi / ARMv7 boards, Alpine on musl with unusual arch, or cross-compiling to an unsupported triple.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at engine/language_client_go/baml_go/lib_common.go:81

		Transport: transport,
		Timeout:   5 * time.Minute,
	}
}

// setOrchestrionInternalFlag tries to set DD__tracer_internal=true using reflection.
// This field is added by Orchestrion's code transformation.
func setOrchestrionInternalFlag(transport *http.Transport) {
	// Use reflection to set the field if it exists
	val := reflect.ValueOf(transport).Elem()
	field := val.FieldByName("DD__tracer_internal")
	if field.IsValid() && field.CanSet() && field.Kind() == reflect.Bool {
		field.SetBool(true)
	}
}

var (
	ErrLoadLibrary          = errors.New("baml: failed loading shared library")
	ErrNotSupportedPlatform = errors.New("baml: platform not supported (only Linux and MacOS amd64/arm64)")
	ErrDownloadFailed       = errors.New("baml: failed to download shared library")
	ErrCacheDir             = errors.New("baml: failed to determine or create cache directory")
	ErrChecksumMismatch     = errors.New("baml: downloaded library checksum mismatch")
	ErrVersionMismatch      = errors.New("baml: library version mismatch")
	ErrInitialization       = errors.New("baml: initialization failed")
)

var (
	bamlSharedLibraryPath = ""
	initErr               error
	initOnce              sync.Once
	bamlLibHandle         unsafe.Pointer
	logger                *slog.Logger
)

func SetSharedLibraryPath(path string) {
	if bamlLibHandle != nil {
		logger.Warn("SetSharedLibraryPath called after BAML library was initialized. Path ignored.", "path", path)

View on GitHub (pinned to bd85ce9dee)