{"record":{"id":"ea818df913eaf725","repo":"anomalyco/sst","slug":"failed-to-open-source-binary-w","errorCode":null,"errorMessage":"failed to open source binary: %w","messagePattern":"failed to open source binary: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/rust/rust.go","lineNumber":152,"sourceCode":"\t\tname = parts[len(parts)-1]\n\t}\n\tbinary := filepath.Join(root, \"target\",\n\t\tmap[bool]string{\n\t\t\ttrue:  filepath.Join(\"debug\", name),\n\t\t\tfalse: filepath.Join(\"lambda\", name, \"bootstrap\"),\n\t\t}[input.Dev],\n\t)\n\tout := filepath.Join(input.Out(), \"bootstrap\")\n\n\tr.directories[input.FunctionID], _ = filepath.Abs(root)\n\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{","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/rust/rust.go#L134-L170","documentation":"Rust runtime Build opens the compiled binary (target/... binary located via the cargo metadata root) and wraps os.Open failures with this message. It means the Rust binary expected at `binary` could not be read — usually the cargo build didn't produce it where the runtime looked.","triggerScenarios":"os.Open(binary) fails because the cargo build output is missing (build skipped/failed earlier but wasn't surfaced), the binary path was computed from the wrong target dir (cross-compile target triple mismatch), or the file was deleted by `cargo clean` between build and copy.","commonSituations":"Cross-compiling (e.g. x86_64-unknown-linux-musl) with the output under target/<triple>/release while the runtime looks in target/release/; cargo build failed or was interrupted; running on an architecture (Apple Silicon) where the default target differs from the expected one.","solutions":["Run `cargo build --release` manually in the project and confirm the binary exists at the path in the error","Verify the target triple matches (use Cargo config [build].target or expected cross-compile flags)","Clean stale target state (`cargo clean`) and redeploy so the binary is rebuilt","Check the rust/ directory path in the SST config points at the crate containing the binary"],"exampleFix":"// before\ncargo build --release // output at target/aarch64-unknown-linux-musl/release/, runtime expects target/release/\n// after\ncargo build --release --target x86_64-unknown-linux-musl // with matching expected target config","handlingStrategy":"validation","validationCode":"# before deploy, confirm the binary exists where the runtime expects it\ncargo build --release\nls target/release/<bin> || ls target/$CARGO_TARGET/release/<bin>","typeGuard":null,"tryCatchPattern":"if err := sstDeploy(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to open source binary\") {\n\t\t// run cargo build --release manually, check target triple, then redeploy\n\t}\n}","preventionTips":["Always run a successful `cargo build --release` before deploying","Match the target triple between cargo config and expected output path","Avoid `cargo clean` between build and deploy","Verify the rust project path in sst.config.ts points at the correct crate"],"tags":["go","rust","filesystem","build"],"backgroundTag":"source-binary-not-found","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}