GoogleContainerTools/skaffold · error
stating file %q: %w
Error message
stating file %q: %w
What it means
Skaffold's SyncMap builds a map of source files to their destinations inside the container for file sync. Before walking, it stats each artifact's 'from' path in the workspace; if os.Stat fails (path missing or inaccessible), the stat error is wrapped with the absolute path and returned, aborting sync-map computation.
Source
Thrown at pkg/skaffold/docker/syncmap.go:74
}
// walkWorkspaceWithDestinations walks the given host directories and determines their
// location in the container. It returns a map of host path by container destination.
// Note: if you change this function, you might also want to modify `WalkWorkspace`.
func walkWorkspaceWithDestinations(workspace string, excludes []string, fts []FromTo) (map[string]string, error) {
dockerIgnored, err := NewDockerIgnorePredicate(workspace, excludes)
if err != nil {
return nil, err
}
// Walk the workspace
srcByDest := make(map[string]string)
for _, ft := range fts {
absFrom := filepath.Join(workspace, ft.From)
fi, err := os.Stat(absFrom)
if err != nil {
return nil, fmt.Errorf("stating file %q: %w", absFrom, err)
}
switch mode := fi.Mode(); {
case mode.IsDir():
keepFile := func(path string, info walk.Dirent) (bool, error) {
if info.IsDir() {
if path == absFrom || util.IsEmptyDir(path) {
return true, nil
}
}
ignored, err := dockerIgnored(path, info)
if err != nil {
return false, err
}
return !ignored, nil
}View on GitHub (pinned to a1189de023)
Solutions
- Verify the sync 'from' path in skaffold.yaml exists relative to the artifact's build context (run ls <workspace>/<from>)
- Run skaffold from the directory containing the workspace, or fix the context field so workspace resolves correctly
- Check file/directory permissions (chmod/chown) if the path exists but stat fails with EACCES
- Remove stale sync entries pointing at deleted files
Example fix
// before (skaffold.yaml)
sync:
manual:
- src: 'src/**/*.ts'
dest: ./app/src
// after — src path must exist under the build context:
// mkdir -p src && ensure *.ts files exist, or correct src: to the real directory Defensive patterns
Strategy: validation
Validate before calling
for _, ft := range fts {
absFrom := filepath.Join(workspace, ft.From)
if _, err := os.Stat(absFrom); err != nil {
return fmt.Errorf("sync source %q missing before SyncMap: %w", absFrom, err)
}
} Type guard
func syncSourceExists(workspace, from string) bool {
_, err := os.Stat(filepath.Join(workspace, from))
return err == nil
} Try / catch
if err := SyncMap(fts, workspace); err != nil {
var pErr *fs.PathError
if errors.As(err, &pErr) && errors.Is(pErr.Err, fs.ErrNotExist) {
log.Warnf("skipping sync: source %q missing", pErr.Path)
return nil
}
return err
} Prevention
- Validate every sync 'from' path against the build context at config-load time
- Keep sync rules generated or linted against the actual source tree
- Run skaffold from the repo root so relative workspaces resolve consistently
- Add a CI check that all skaffold.yaml sync sources exist
When it happens
Trigger: Calling SyncMap for an artifact whose build context lists a sync rule with a 'from' path (ft.From) that does not exist or is unreadable under the workspace directory; os.Stat returns e.g. ENOENT, EACCES, or the path is a broken symlink.
Common situations: Typo in skaffold.yaml sync 'from' path; sync source deleted/renamed after config was written; running skaffold dev from the wrong working directory so the workspace path resolves incorrectly; permission-restricted checkout (CI running as non-root over root-owned files).
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- walking workspace: %w
- walking %q: %w
- unable to stat file %q: %w
- intersecting sync map and added, modified files: %w
- intersecting sync map and deleted files: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/603b2a27d29ad195.
Report an issue: GitHub.