{"record":{"id":"ae958542bbf9e638","repo":"anomalyco/sst","slug":"failed-to-copy-binary-w","errorCode":null,"errorMessage":"failed to copy binary: %w","messagePattern":"failed to copy binary: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/rust/rust.go","lineNumber":163,"sourceCode":"\n\tif err := os.MkdirAll(filepath.Dir(out), 0755); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create output directory: %w\", err)\n\t}\n\n\tsource, err := os.Open(binary)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open source binary: %w\", err)\n\t}\n\tdefer source.Close()\n\n\tdestination, err := os.Create(out)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create destination file: %w\", err)\n\t}\n\tdefer destination.Close()\n\n\tif _, err := io.Copy(destination, source); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to copy binary: %w\", err)\n\t}\n\n\tif err := os.Chmod(out, 0755); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to make binary executable: %w\", err)\n\t}\n\n\treturn &runtime.BuildOutput{\n\t\tHandler:    \"bootstrap\",\n\t\tSourcemaps: []string{},\n\t\tErrors:     []string{},\n\t\tOut:        root,\n\t}, nil\n}\n\nfunc (r *Runtime) Run(ctx context.Context, input *runtime.RunInput) (runtime.Worker, error) {\n\tcmd := process.Command(\n\t\tfilepath.Join(input.Build.Out, input.Build.Handler),\n\t)","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/rust/rust.go#L145-L181","documentation":"During the Rust runtime build, after `cargo` produces the compiled binary, SST copies it to the function output directory as `bootstrap`. This error wraps any `io.Copy` failure between the source binary and the destination file — typically a disk-level or I/O problem, not a compile error (cargo failures fail earlier with their own message).","triggerScenarios":"`io.Copy(destination, source)` returns an error while copying `target/{debug|lambda/<name>}/bootstrap` to the function's `.sst` build output — e.g. disk full (ENOSPC), source binary deleted mid-read, destination file truncated, or a filesystem/EFS error.","commonSituations":"Ran out of disk space in `~/.cargo`/`target` heavy projects; concurrent `sst build` runs racing on the same target directory; container/CI with small ephemeral disks; antivirus or file watchers locking the file during copy.","solutions":["Free up disk space (`df -h`) and clear large `target/` directories with `cargo clean`, then rebuild","Re-run `sst build` / `sst dev` — transient I/O errors often clear on retry","Check for concurrent SST/cargo processes on the same project and stop them","Verify the output filesystem is writable and not full or mounted read-only"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before deploy: check free space and the built binary\nconst stat = fs.statSync(path.join(crateRoot, \"target\", \"lambda\", name, \"bootstrap\"));\nif (stat.size <= 0) throw new Error(\"cargo produced an empty binary\");\nconst free = checkDiskSpace(process.cwd()); // e.g. via 'check-disk-space' pkg\nif (free.free < 1024 * 1024 * 1024) throw new Error(\"need >=1GB free disk space\");","typeGuard":null,"tryCatchPattern":"try {\n  await run(\"sst\", [\"build\"]);\n} catch (e) {\n  if (/failed to copy binary/.test(String(e))) {\n    await exec(\"cargo\", [\"clean\"]);\n    await run(\"sst\", [\"build\"]); // retry after freeing space\n  } else throw e;\n}","preventionTips":["Monitor disk space in CI; clean `target/` caches regularly","Avoid running multiple concurrent builds in the same project directory","Keep `.sst` output on a local POSIX filesystem, not a network mount"],"tags":["rust","build","filesystem","io"],"backgroundTag":"disk-full-io-error","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}