GoogleContainerTools/skaffold · error

walking %q: %w

Error message

walking %q: %w

What it means

WalkWorkspace walks the build workspace directory (respecting exclude predicates) to collect dependency files for a Docker image build. This error wraps any failure returned by the underlying filepath/fs walker (walk.From root.Walk) with the offending absolute path %q and the cause via %w. It signals that the directory traversal itself aborted, so the full dependency file set could not be computed.

Source

Thrown at pkg/skaffold/docker/dependencies.go:278

			if err != nil {
				return false, err
			}
			return !ignored, nil
		}

		if err := walk.From(absFrom).Unsorted().When(keepFile).Do(func(path string, info walk.Dirent) error {
			relPath, err := filepath.Rel(workspace, path)
			if err != nil {
				return err
			}

			if !info.IsDir() || util.IsEmptyDir(path) {
				files[relPath] = true
			}

			return nil
		}); err != nil {
			return nil, fmt.Errorf("walking %q: %w", absFrom, err)
		}
	}

	return files, nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Fix filesystem permissions: chmod/chown the workspace so the user running skaffold can read all subdirectories.
  2. Inspect the wrapped error (it names absFrom and the cause) and address the specific failing path, e.g. remove or repair broken symlinks.
  3. Ensure no process is deleting/moving files under the workspace while skaffold computes dependencies.
  4. Add problematic paths (large vendored dirs, secrets) to .dockerignore or skaffold exclude patterns so they are skipped, then retry the build.

Example fix

// before (shell): build fails with walking "/repo/node_modules": permission denied
$ skaffold build

// after: fix permissions or exclude the path
$ sudo chmod -R a+rX /repo/node_modules
# or in skaffold.yaml build.artifacts[*].sync/skaffold excludes + .dockerignore
node_modules
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: pre-check workspace readability before WalkWorkspace
if fi, err := os.Stat(workspace); err != nil {
    return fmt.Errorf("workspace %q inaccessible: %w", workspace, err)
}
if err := filepath.Walk(workspace, func(p string, _ os.FileInfo, err error) error {
    if err != nil { return err }
    if fi, err := os.Stat(p); err != nil || fi.Mode()&0o400 == 0 { return fmt.Errorf("unreadable: %s", p) }
    return nil
}); err != nil {
    return fmt.Errorf("pre-check failed: %w", err)
}

Try / catch

files, err := docker.WalkWorkspace(workspace, excludes, deps)
if err != nil {
    var perr *fs.PathError
    if errors.As(err, &perr) {
        log.Warnf("walk failed on %s: %v — fixing perms/excludes and retrying", perr.Path, perr.Err)
        return retryWithNarrowedExcludes(workspace, excludes, perr.Path)
    }
    return fmt.Errorf("dependency walk failed: %w", err)
}

Prevention

When it happens

Trigger: Calling WalkWorkspace(workspace, excludes, deps) (directly or via getDependencies / getDependenciesByDockerCopyFromTo during skaffold build/dev) where the walk rooted at the workspace errors: permission denied on a subdirectory, a symlink loop, a directory deleted mid-walk, or the walk callback returning an error (e.g. from NewDockerIgnorePredicate path computation).

Common situations: Building inside a container or CI where the mounted workspace lacks read permissions on some subdirectories; workspace on a flaky network filesystem (NFS) where entries vanish during traversal; broken symlinks in node_modules or vendored directories; workspaces containing permission-locked secrets folders.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/327f485458c23086. Report an issue: GitHub.