anomalyco/sst · error

failed to create destination file: %w

Error message

failed to create destination file: %w

What it means

Rust runtime Build creates the destination bootstrap file inside the bundle with os.Create and wraps failures with this message. Both the output directory and the source binary were fine, but creating the destination file failed — destination is a directory, permissions deny write, or the filesystem is full.

Source

Thrown at pkg/runtime/rust/rust.go:158

		}[input.Dev],
	)
	out := filepath.Join(input.Out(), "bootstrap")

	r.directories[input.FunctionID], _ = filepath.Abs(root)

	if err := os.MkdirAll(filepath.Dir(out), 0755); err != nil {
		return nil, fmt.Errorf("failed to create output directory: %w", err)
	}

	source, err := os.Open(binary)
	if err != nil {
		return nil, fmt.Errorf("failed to open source binary: %w", err)
	}
	defer source.Close()

	destination, err := os.Create(out)
	if err != nil {
		return nil, fmt.Errorf("failed to create destination file: %w", err)
	}
	defer destination.Close()

	if _, err := io.Copy(destination, source); err != nil {
		return nil, fmt.Errorf("failed to copy binary: %w", err)
	}

	if err := os.Chmod(out, 0755); err != nil {
		return nil, fmt.Errorf("failed to make binary executable: %w", err)
	}

	return &runtime.BuildOutput{
		Handler:    "bootstrap",
		Sourcemaps: []string{},
		Errors:     []string{},
		Out:        root,
	}, nil
}

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Remove any directory/file named `bootstrap` blocking the output path
  2. Check free space and write permissions on the function output directory
  3. Redeploy after clearing the corrupted .sst output for that function
  4. Inspect the wrapped os error text for the exact underlying cause
Defensive patterns

Strategy: validation

Validate before calling

const bootstrap = path.join(outDir, "bootstrap")
if (fs.existsSync(bootstrap)) fs.rmSync(bootstrap, { recursive: true })
fs.accessSync(outDir, fs.constants.W_OK)

Try / catch

if err := sstDeploy(); err != nil {
	if strings.Contains(err.Error(), "failed to create destination file") {
		// remove stale 'bootstrap' entry / free space, then redeploy
	}
}

Prevention

When it happens

Trigger: os.Create(out) errors where out = filepath.Join(input.Out(), "bootstrap"): a directory named `bootstrap` already exists in the output, the output dir is unwritable for the current user, or the volume is out of space/inodes.

Common situations: Previous failed deploy left `bootstrap` as a directory; running in a rootless container with a read-only bundle mount; disk quota exhausted on the build output volume.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/05e2432a1e778308. Report an issue: GitHub.