github/copilot-sdk · error
failed to hash runtime assets
Error message
failed to hash runtime assets: %w
What it means
This error wraps a failure from sha256File when hashing the freshly created runtime assets archive. The bundler computes the SHA-256 digest to embed in bundle metadata; if the file cannot be opened or read, buildBundle fails with this message.
Solutions
- Re-run the bundler; transient read errors usually clear on retry
- Confirm the assets artifact path exists and is readable in the output directory (ls -l)
- Check disk health / available space on the output volume
- Log the wrapped cause (%w) to distinguish open failures from read failures
Example fix
// before
assetsHash, err := sha256File(assetsArtifactPath)
if err != nil {
return bundleArtifacts{}, fmt.Errorf("failed to hash runtime assets: %w", err)
}
// after
assetsHash, err := sha256File(assetsArtifactPath)
if err != nil {
if os.IsNotExist(err) {
return bundleArtifacts{}, fmt.Errorf("runtime assets missing at %s: %w", assetsArtifactPath, err)
}
return bundleArtifacts{}, fmt.Errorf("failed to hash runtime assets: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if fi, err := os.Stat(assetsArtifactPath); err != nil || fi.Size() == 0 {
return fmt.Errorf("assets artifact %s missing or empty before hashing", assetsArtifactPath)
} Try / catch
assetsHash, err := sha256File(assetsArtifactPath)
if err != nil {
if os.IsNotExist(err) { /* regenerate archive and retry once */ }
return fmt.Errorf("failed to hash runtime assets: %w", err)
} Prevention
- Hash immediately after creating the archive in the same process/directory
- Avoid shared temp dirs where other processes can delete artifacts
- Monitor disk health on build machines
- Retry the build once on transient read errors
When it happens
Trigger: sha256File(assetsArtifactPath) returns an error right after createRuntimeAssetsArchive succeeds — typically the assets file is missing/unreadable or an I/O error occurs while reading it.
Common situations: Antivirus or another process removing temp files between creation and hashing; disk read errors; permissions changed on the output directory; filesystem race in a shared tmpdir.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- failed to write runtime assets
- runtime package contains no retained assets
- failed to read existing Go file
- Failed to read runtime package entry
- SessionFS.InitialWorkingDirectory is required
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/71676825905f4e8d.
Report an issue: GitHub.
Appendix: source
Thrown at go/cmd/bundler/main.go:503
tempDir,
"package/prebuilds/"+info.runtimePlatform+"/"+wrapperName,
wrapperName,
); err != nil {
return bundleArtifacts{}, fmt.Errorf("runtime package is missing prebuilds/%s/%s: %w", info.runtimePlatform, wrapperName, err)
}
wrapperHash, err := sha256File(rawWrapperPath)
if err != nil {
return bundleArtifacts{}, fmt.Errorf("failed to hash runtime wrapper: %w", err)
}
if err := compressZstdFile(rawWrapperPath, wrapperArtifactPath); err != nil {
return bundleArtifacts{}, fmt.Errorf("failed to write runtime wrapper: %w", err)
}
if err := createRuntimeAssetsArchive(tarballPath, assetsArtifactPath, info); err != nil {
return bundleArtifacts{}, fmt.Errorf("failed to write runtime assets: %w", err)
}
assetsHash, err := sha256File(assetsArtifactPath)
if err != nil {
return bundleArtifacts{}, fmt.Errorf("failed to hash runtime assets: %w", err)
}
fmt.Printf("Successfully created %s\n", outputPath)
fmt.Printf("Successfully created %s\n", runtimeArtifactPath)
fmt.Printf("Successfully created %s\n", wrapperArtifactPath)
fmt.Printf("Successfully created %s\n", assetsArtifactPath)
return bundleArtifacts{outputPath, binaryHash, runtimeArtifactPath, runtimeHash, wrapperArtifactPath, wrapperHash, assetsArtifactPath, assetsHash}, nil
}
func filesExist(paths ...string) bool {
for _, path := range paths {
if _, err := os.Stat(path); err != nil {
return false
}
}
return true
}
View on GitHub (pinned to cd8cf15dc3)