anomalyco/sst · error
failed to open file for hashing: %w
Error message
failed to open file for hashing: %w
What it means
hashFileContents opens a file to compute its SHA256 and wraps os.Open failures with this message. The library throws it from copySyncedDependencies, which hashes files to detect changes for dev-mode sync. It means the file that the dependency list referenced could not be opened for reading at hash time.
Source
Thrown at pkg/runtime/python/python.go:458
if skip(relPath, info) {
if info.IsDir() {
return filepath.SkipDir
}
return nil
}
dstPath := filepath.Join(dst, relPath)
if info.IsDir() {
return os.MkdirAll(dstPath, info.Mode())
}
return copyFile(p, dstPath)
})
}
// hashFileContents computes a SHA256 hash of a file's contents.
func hashFileContents(filePath string) (string, error) {
file, err := os.Open(filePath)
if err != nil {
return "", fmt.Errorf("failed to open file for hashing: %w", err)
}
defer file.Close()
hasher := sha256.New()
if _, err := io.Copy(hasher, file); err != nil {
return "", fmt.Errorf("failed to hash file: %w", err)
}
return hex.EncodeToString(hasher.Sum(nil)), nil
}
// hasWorkspaceLayoutPatterns checks for package/src/package patterns that need flattening.
// Scans up to one level below projectRoot to cover both single-package and monorepo layouts.
func (r *PythonRuntime) hasWorkspaceLayoutPatterns(projectRoot string) bool {
var scan func(dir string, depth int) bool
scan = func(dir string, depth int) bool {
entries, err := os.ReadDir(dir)
if err != nil {View on GitHub (pinned to a0bd20f762)
Solutions
- Verify the file exists at the hashed path (ls / stat) and recreate it if it was deleted
- Restart `sst dev` so the dependency list and hashes are recomputed
- Check file permissions/ownership of the dependency files
- If files are frequently mid-write, ignore ENOENT for files that vanished during sync
Defensive patterns
Strategy: validation
Validate before calling
func fileExists(path string) bool {
fi, err := os.Stat(path)
return err == nil && fi.Mode().IsRegular()
}
// before syncing: ensure every dependency path hashes-exists
// if !fileExists(depPath) { recompute dependency list or skip } Try / catch
if err := sstDev(); err != nil {
if strings.Contains(err.Error(), "failed to open file for hashing") {
// file vanished or is unreadable: restart dev to rebuild dependency list
}
} Prevention
- Restart `sst dev` after moving/renaming workspace packages
- Check permissions/ownership of dependency files (especially when mixing root and user runs)
- Treat ENOENT on vanished files as skip rather than hard failure in custom tooling
- Avoid running `cargo clean`-style cleanup tasks while dev sync is active
When it happens
Trigger: copySyncedDependencies calls hashFileContents(path) on a path that no longer exists (file deleted between dependency discovery and hashing) or is unreadable (permissions, symlink to nonexistent target, path too long).
Common situations: File removed by a concurrent build/clean while `sst dev` is syncing; stale cache pointing at an old dependency path; workspace package relocated or renamed; restrictive umask/permissions on files generated by another user (e.g. root in Docker).
Related errors
- failed to hash file: %w
- error walking target directory during cleanup: %w
- failed to read source directory: %w
- failed to create destination file: %w
- failed to copy file contents: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/fba887c1b91efd87.
Report an issue: GitHub.