GoogleContainerTools/skaffold · error

image %q context %q does not exist

Error message

image %q context %q does not exist

What it means

CheckWorkspaces validates, before building, that every artifact with a non-empty Workspace exists and is a directory. If os.Stat reports the workspace does not exist, this error names both the image and the missing context dir. Distinct messages cover permission errors and non-directory paths.

Source

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

	var bRes []graph.Artifact
	for _, artifact := range artifacts {
		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. Verify the context path in skaffold.yaml exists relative to the skaffold.yaml location: `ls <context>`
  2. Fix the typo or create the missing directory (with a Dockerfile/source)
  3. If running in CI, ensure the directory is checked out/mounted before build
  4. If the error is permission-related instead, the sibling error will include the OS err — fix chmod accordingly

Example fix

// before (skaffold.yaml)
build:
  artifacts:
    - image: app
      context: ./backend-service   # directory does not exist
// after
build:
  artifacts:
    - image: app
      context: ./services/backend
Defensive patterns

Strategy: validation

Validate before calling

func checkWorkspaces(artifacts []*latest.Artifact) error {
    for _, a := range artifacts {
        if a.Workspace == "" { continue }
        fi, err := os.Stat(a.Workspace)
        if err != nil { return fmt.Errorf("missing context %s", a.Workspace) }
        if !fi.IsDir() { return fmt.Errorf("context %s is not a dir", a.Workspace) }
    }
    return nil
}
// call before Build

Try / catch

if err := CheckWorkspaces(artifacts); err != nil {
    return fmt.Errorf("pre-build check failed: %w", err)
}

Prevention

When it happens

Trigger: Build -> CheckWorkspaces: an artifact's Workspace path (build context from skaffold.yaml) does not exist on disk at build time.

Common situations: skaffold.yaml context path typo; build context directory not committed / not mounted in CI; path relative to the wrong working directory; artifact generated from profiles pointing at a removed directory.

Related errors


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