GoogleContainerTools/skaffold · error

image %q context %q: %w

Error message

image %q context %q: %w

What it means

Skaffold's CheckWorkspaces validates each build artifact's build context before building. This error wraps the underlying os.Stat error when the artifact's `workspace` path exists in some form but cannot be accessed (e.g. permission denied, too many symlinks). It is wrapped with %w so the original OS error (e.g. 'permission denied') is preserved in the chain.

Source

Thrown at pkg/skaffold/runner/build.go:158

		bRes = append(bRes, graph.Artifact{
			ImageName:   artifact.ImageName,
			Tag:         tags[artifact.ImageName],
			RuntimeType: artifact.RuntimeType,
		})
	}

	return bRes
}

func CheckWorkspaces(artifacts []*latest.Artifact) error {
	for _, a := range artifacts {
		if a.Workspace != "" {
			if info, err := os.Stat(a.Workspace); err != nil {
				// err could be permission-related
				if os.IsNotExist(err) {
					return fmt.Errorf("image %q context %q does not exist", a.ImageName, a.Workspace)
				}
				return fmt.Errorf("image %q context %q: %w", a.ImageName, a.Workspace, err)
			} else if !info.IsDir() {
				return fmt.Errorf("image %q context %q is not a directory", a.ImageName, a.Workspace)
			}
		}
	}
	return nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Run `ls -la` on the workspace path and fix permissions (`chmod`/`chown`) so the skaffold process can stat it
  2. If running in a container/CI, mount the context directory with correct ownership and permissions
  3. If the path actually does not exist, fix the `context:` value in skaffold.yaml (that case produces the 'does not exist' variant instead)

Example fix

// before (skaffold.yaml)
build:
  artifacts:
    - image: app
      context: ./secure-context   # owned by root, mode 0700
// after
sudo chown -R $USER ./secure-context && chmod -R u+rx ./secure-context
Defensive patterns

Strategy: validation

Validate before calling

const ws = artifact.Workspace
try {
  const info = await fs.promises.stat(ws)
  if (!info.isDirectory()) throw new Error(`${ws} is not a directory`)
} catch (e) {
  throw new Error(`workspace ${ws} not accessible: ${e.message}`)
}

Prevention

When it happens

Trigger: A build artifact in skaffold.yaml defines `context`/`workspace` pointing to a path where os.Stat fails with an error that is NOT os.IsNotExist — e.g. a directory with no read/execute permission for the current user, or a broken loop of symlinks.

Common situations: Cloning a repo on Linux with files owned by another user; running skaffold inside a container where the context directory has restrictive permissions; CI runners dropping privileges before the build.

Related errors


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