{"record":{"id":"6835dfdc9c484dbd","repo":"GoogleContainerTools/skaffold","slug":"unable-to-stat-file-q-w","errorCode":null,"errorMessage":"unable to stat file %q: %w","messagePattern":"unable to stat file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/filemon/changes.go","lineNumber":47,"sourceCode":"\n// FileMap is a map of filename to modification times.\ntype FileMap map[string]time.Time\n\n// Stat returns the modification times for a list of files.\nfunc Stat(deps func() ([]string, error)) (FileMap, error) {\n\tstate := FileMap{}\n\tpaths, err := deps()\n\tif err != nil {\n\t\treturn state, fmt.Errorf(\"listing files: %w\", err)\n\t}\n\tfor _, path := range paths {\n\t\tstat, err := os.Stat(path)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tlog.Entry(context.TODO()).Debugf(\"could not stat dependency: %s\", err)\n\t\t\t\tcontinue // Ignore files that don't exist\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"unable to stat file %q: %w\", path, err)\n\t\t}\n\t\tstate[path] = stat.ModTime()\n\t}\n\n\treturn state, nil\n}\n\ntype Events struct {\n\tAdded    []string\n\tModified []string\n\tDeleted  []string\n}\n\nfunc (e Events) HasChanged() bool {\n\treturn len(e.Added) != 0 || len(e.Deleted) != 0 || len(e.Modified) != 0\n}\n\nfunc (e *Events) String() string {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/filemon/changes.go#L29-L65","documentation":"Skaffold's file monitor builds a map of file paths to modification times by calling os.Stat on each registered dependency. If Stat fails for a reason other than 'file does not exist' (missing files are deliberately skipped), the walk cannot proceed reliably, so it aborts with this wrapped error naming the path and the underlying cause.","triggerScenarios":"Calling Register, Run, or timeToComputeMTimes (directly or via the file watcher) on a path that exists but is not statable: permission denied on a directory component, an I/O error, a broken symlink on some filesystems, a path that is too long, or a dangling mount/NFS stale handle.","commonSituations":"Running Skaffold in a container without read permission on a watched directory; watching a directory on a network volume that dropped; a dependency path inside a directory with restrictive permissions after a chmod change; watching files under /proc or another pseudo-filesystem where stat can fail transiently.","solutions":["Fix the underlying os.Stat error shown in the wrapped cause (permissions, stale mount, I/O).","Check that the watched path exists and all parent directories grant read+execute to the user running Skaffold.","Remove or correct the offending dependency/glob in skaffold.yaml if it points at a pseudo-filesystem or unstable path.","Re-run as a user with sufficient permissions, or remount the volume."],"exampleFix":"// before (watching a root-owned dir without perms)\nwatchedPaths:\n  - /var/run/secrets/...\n// after (watch an accessible copy or fix perms)\nsudo chmod o+rx /var/run/secrets\n# or point build artifacts to a user-writable dir","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(path); err != nil && !os.IsNotExist(err) {\n    return fmt.Errorf(\"path %q is not statable: %w\", path, err)\n}","typeGuard":"func isNotExistErr(err error) bool {\n    return errors.Is(err, os.ErrNotExist)\n}","tryCatchPattern":"state, err := Stat(paths)\nif err != nil {\n    var pe *os.PathError\n    if errors.As(err, &pe) {\n        log.Warnf(\"skipping unstattable path %s: %v\", pe.Path, err)\n    }\n    return err\n}","preventionTips":["Pre-flight os.Stat every watched path at startup and log/remove failures.","Ensure watched directories grant read+execute to the Skaffold process user.","Avoid watching pseudo-filesystems (/proc, /sys) and NFS mounts in dependencies.","Handle os.ErrNotExist separately — it is intentionally tolerated by the monitor."],"tags":["filesystem","filemon","stat","permissions"],"backgroundTag":"stat-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}