{"record":{"id":"afc6b0f26ec4e801","repo":"abiosoft/colima","slug":"cannot-stat-file-s-w","errorCode":null,"errorMessage":"cannot stat file '%s': %w","messagePattern":"cannot stat file '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/file.go","lineNumber":74,"sourceCode":"\t\treturn info, statError(filename, err)\n\t}\n\tinfo.name = filename\n\tinfo.size, _ = strconv.ParseInt(stats[0], 10, 64)\n\tinfo.mode = func() fs.FileMode {\n\t\tmode, _ := strconv.ParseUint(stats[1], 10, 32)\n\t\treturn fs.FileMode(mode)\n\t}()\n\tinfo.modTime = func() time.Time {\n\t\tunix, _ := strconv.ParseInt(stats[2], 10, 64)\n\t\treturn time.Unix(unix, 0)\n\t}()\n\tinfo.isDir = stats[3] == \"directory\"\n\n\treturn info, nil\n}\n\nfunc statError(filename string, err error) error {\n\treturn fmt.Errorf(\"cannot stat file '%s': %w\", filename, err)\n}\n\n// IsDir implements fs.FileInfo\nfunc (f fileInfo) IsDir() bool { return f.isDir }\n\n// ModTime implements fs.FileInfo\nfunc (f fileInfo) ModTime() time.Time { return f.modTime }\n\n// Mode implements fs.FileInfo\nfunc (f fileInfo) Mode() fs.FileMode { return f.mode }\n\n// Name implements fs.FileInfo\nfunc (f fileInfo) Name() string { return f.name }\n\n// Size implements fs.FileInfo\nfunc (f fileInfo) Size() int64 { return f.size }\n\n// Sys implements fs.FileInfo","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/file.go#L56-L92","documentation":"statError is the single wrapping helper for guest-side file stat failures in limaVM.Stat/newFileInfo: the stat is performed by running a stats command in the guest and parsing its output; any execution or parse-level failure is returned as \"cannot stat file '<name>'\". It is the limaVM equivalent of os.Stat's error, carrying the guest command error as the cause.","triggerScenarios":"Calling Stat for a path that does not exist in the guest; guest not running / SSH failing so the stats command errors; parse failures when the guest output shape is unexpected (nonstandard coreutils in custom images).","commonSituations":"Runtime integrations probing for the existence of sockets/config files in the guest before acting; startup flows that check containerd/docker state files.","solutions":["Use it as an existence check: a non-nil error means absent-or-unreachable; distinguish by first checking vm.Running(ctx).","Confirm the path with `colima ssh -- stat <path>`.","Retry after the guest has fully started when racing boot.","For custom images, ensure standard GNU coreutils behavior for stat-like output."],"exampleFix":"// before\nif _, err := vm.Stat(\"/run/containerd/containerd.sock\"); err != nil { return err }\n\n// after\nif _, err := vm.Stat(\"/run/containerd/containerd.sock\"); err != nil {\n    if !vm.Running(ctx) { return fmt.Errorf(\"vm not running: %w\", err) }\n    // treat as not-yet-created: wait or skip\n}","handlingStrategy":"validation","validationCode":"// existence check pattern around Stat\nif !vm.Running(ctx) { return errors.New(\"vm not running; cannot stat\") }\n_, err := vm.Stat(fileName)\nexists := err == nil","typeGuard":null,"tryCatchPattern":"Go: treat any stat error as not-exists only when vm.Running(ctx) is true; otherwise surface the state problem.","preventionTips":["Always pair Stat with a Running check","Use colima ssh to verify unexpected stat failures","Don't parse the error string for type; re-stat after guest boot settles"],"tags":["stat","file","guest","ssh","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}