BoundaryML/baml · error

failed copying from to

Error message

failed copying from %s to %s: %w

What it means

copyFile (called by downloadBamlLibrary) wraps io.Copy failures with this message, indicating the byte transfer from the source (downloaded artifact) to the destination file failed partway. The %w preserves the underlying read/write error.

Solutions

  1. Free disk space on the destination volume and retry
  2. Ensure only one process is performing the download/copy at a time (avoid concurrent builds sharing the cache)
  3. Check for antivirus/quarantine tools interfering with the destination path
  4. Delete the partial destination file and re-trigger downloadBamlLibrary
Defensive patterns

Strategy: retry

Validate before calling

if fi, err := os.Stat(src); err != nil || fi.Size() == 0 {
    return fmt.Errorf("source artifact missing or empty")
}

Try / catch

for attempt := 0; attempt < 3; attempt++ {
    err := baml.DownloadLibrary(dst)
    if err == nil || !strings.Contains(err.Error(), "failed copying") {
        return err
    }
    time.Sleep(backoff(attempt))
}

Prevention

When it happens

Trigger: io.Copy returns non-nil: source read fails (source file removed/truncated mid-copy) or destination write fails (disk full, I/O error) while copying the BAML native library artifact.

Common situations: Disk filling up during first-run native library download; concurrent processes writing the same temp file; antivirus or container storage issues interrupting writes.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

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

	if err != nil {
		return fmt.Errorf("failed open source %s: %w", src, err)
	}
	defer source.Close()

	destination, err := os.Create(dst)
	if err != nil {
		return fmt.Errorf("failed create destination %s: %w", dst, err)
	}
	defer func() {
		cerr := destination.Close()
		if err == nil && cerr != nil {
			err = fmt.Errorf("failed close destination %s: %w", dst, cerr)
		}
	}()

	_, err = io.Copy(destination, source)
	if err != nil {
		return fmt.Errorf("failed copying from %s to %s: %w", src, dst, err)
	}

	err = destination.Sync()
	if err != nil {
		return fmt.Errorf("failed syncing destination %s: %w", dst, err)
	}

	logger.Debug("File copied successfully", "source", src, "destination", dst)
	return nil
}

func isSupportedPlatform() bool {
	osOk := runtime.GOOS == "darwin" || runtime.GOOS == "linux" || runtime.GOOS == "windows"
	archOk := runtime.GOARCH == "amd64" || runtime.GOARCH == "arm64"
	return osOk && archOk
}

func initSlog() {

View on GitHub (pinned to bd85ce9dee)