abiosoft/colima · error
cannot open file for validation: %w
Error message
cannot open file for validation: %w
What it means
validateFile could not os.Open the file it is about to hash. The wrapped *fs.PathError means the path does not exist (ENOENT), is a directory, or is unreadable (EACCES). In the internal flow the file was just written, so this mostly appears when SHA.ValidateFile is called directly with a stale path or the cache entry vanished between download and validation.
Source
Thrown at util/downloader/sha.go:36
// SHA is the shasum of a file.
type SHA struct {
Digest string // shasum
URL string // url to download the shasum file (if Digest is empty)
Size int // one of 256 or 512
}
// ValidateFile validates the SHA of the file.
// The host parameter is kept for API compatibility but is not used.
func (s SHA) ValidateFile(host hostActions, file string) error {
return s.validateFile(file)
}
// validateFile performs SHA validation using pure Go crypto.
func (s SHA) validateFile(file string) error {
// open the file
f, err := os.Open(file)
if err != nil {
return fmt.Errorf("cannot open file for validation: %w", err)
}
defer func() { _ = f.Close() }()
// select hash algorithm
var h hash.Hash
switch s.Size {
case 256:
h = sha256.New()
case 512:
h = sha512.New()
default:
return fmt.Errorf("unsupported SHA size: %d (must be 256 or 512)", s.Size)
}
// compute hash
if _, err := io.Copy(h, f); err != nil {
return fmt.Errorf("error reading file for SHA validation: %w", err)
}View on GitHub (pinned to c3a5f9184d)
Solutions
- ls -l the exact path from the error and correct it
- Re-run the download to regenerate the cache entry
- Check read permission on the file and every parent directory
Defensive patterns
Strategy: validation
Validate before calling
if fi, err := os.Stat(path); err != nil {
return fmt.Errorf("cache entry missing, re-download before validating: %w", err)
} else if fi.IsDir() {
return errors.New("validation target is a directory, expected a file")
}
err := sha.ValidateFile(host, path) Prevention
- Stat the file immediately before validating; never cache paths across long operations
- Derive the path from downloader.CacheFilename instead of hand-built strings
When it happens
Trigger: Calling SHA.ValidateFile with a path whose file was moved/deleted (cache cleared mid-operation); wrong path (relative vs absolute, typo); file without read permission for the current user.
Common situations: Cache purged while an operation runs; validating a file after it was relocated; validating inside a context with reduced permissions.
Related errors
- mount path with spaces is not supported by the underlying Li
- overlapping mounts not supported: %w
- error reading file for SHA validation: %w
- relative paths not supported for mount '%s'
- error persisting runtime settings: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/e48b25f4840328db.
Report an issue: GitHub.