{"record":{"id":"002f3abf15fd98a1","repo":"github/copilot-sdk","slug":"binary-not-found-after-extraction-w","errorCode":null,"errorMessage":"binary not found after extraction: %w","messagePattern":"binary not found after extraction: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":1054,"sourceCode":"\n\t// The SDK release package intentionally omits the legacy SEA binary. Preserve\n\t// embeddedcli.Path compatibility by installing the runtime wrapper under the\n\t// historical copilot[.exe] name; the normal client path uses the adjacent\n\t// wrapper/runtime.node pair directly.\n\tbinaryPath := filepath.Join(destDir, binaryName)\n\twrapperName := runtimeWrapperName(binaryName)\n\tif err := extractFileFromTarball(\n\t\ttarballPath,\n\t\tdestDir,\n\t\t\"package/prebuilds/\"+runtimePlatform+\"/\"+wrapperName,\n\t\tbinaryName,\n\t); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to extract runtime wrapper compatibility entrypoint: %w\", err)\n\t}\n\n\t// Verify binary exists\n\tif _, err := os.Stat(binaryPath); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"binary not found after extraction: %w\", err)\n\t}\n\n\t// Make executable on Unix\n\tif !strings.HasSuffix(binaryName, \".exe\") {\n\t\tif err := os.Chmod(binaryPath, 0755); err != nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"failed to chmod binary: %w\", err)\n\t\t}\n\t}\n\n\tstat, err := os.Stat(binaryPath)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to stat binary: %w\", err)\n\t}\n\tsizeMB := float64(stat.Size()) / 1024 / 1024\n\tfmt.Printf(\"Downloaded %s (%.1f MB)\\n\", binaryName, sizeMB)\n\n\treturn binaryPath, tarballPath, nil\n}","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L1036-L1072","documentation":"Immediately after extraction, the bundler stats the expected binary path to confirm the wrapper entrypoint actually landed in destDir. If os.Stat fails, the file is missing (or unreadable) despite extraction reporting success, and this error wraps the stat error. It's a post-extraction sanity check.","triggerScenarios":"os.Stat(binaryPath) returns non-nil right after extractFileFromTarball succeeded — the binary was written to an unexpected path, deleted, or destDir was modified between extraction and stat.","commonSituations":"Antivirus/EDR quarantining freshly extracted executables; concurrent builds sharing destDir and clobbering files; extraction writing under a slightly different name; permissions on destDir changed mid-build.","solutions":["Check antivirus/EDR logs for quarantine of the extracted binary and add an exclusion.","Ensure no concurrent process cleans or mutates destDir during buildBundle.","Verify binaryName/path construction matches what extractFileFromTarball writes.","Re-run the build; a transient filesystem race usually won't recur."],"exampleFix":"// before: shared mutable destDir across parallel builds\n// after: unique per-build destination\ndestDir = filepath.Join(baseDir, fmt.Sprintf(\"build-%d\", os.Getpid()))","handlingStrategy":"try-catch","validationCode":"// ensure destDir is writable and not subject to external cleanup\nif err := os.MkdirAll(destDir, 0o755); err != nil { return err }\nif f, err := os.CreateTemp(destDir, \".probe\"); err != nil { return err } else { f.Close(); os.Remove(f.Name()) }","typeGuard":null,"tryCatchPattern":"if err := buildBundle(...); err != nil {\n    if strings.Contains(err.Error(), \"binary not found after extraction\") {\n        checkAVQuarantineLog(); retryInIsolatedDir()\n    }\n}","preventionTips":["Add AV/EDR exclusions for your build output directories.","Use per-process/per-build destination directories to avoid races.","Never share one destDir across concurrent buildBundle runs.","Re-check that binaryName construction matches extraction targets."],"tags":["filesystem","extraction","go","verification"],"backgroundTag":"file-not-found","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}