GoogleContainerTools/skaffold · error

cannot locate kustomization file from provided directory: %s

Error message

cannot locate kustomization file from provided directory: %s

What it means

getKustomizationFile probes a set of well-known kustomization filenames (kustomization.yaml, kustomization.yml, Kustomization) with os.Stat in the given directory; if none exist it returns this error. It surfaces when mirroring the kustomize root into a temp filesystem before rendering.

Source

Thrown at pkg/skaffold/render/renderer/kustomize/kustomize.go:156

	if useKubectlKustomize {
		return kCLI.Kustomize(ctx, kustomizeBuildArgs(k.rCfg.Kustomize.BuildArgs, kustomizePath))
	} else {
		cmd := exec.CommandContext(ctx, "kustomize", append([]string{"build"}, kustomizeBuildArgs(k.rCfg.Kustomize.BuildArgs, kustomizePath)...)...)
		return sUtil.RunCmdOut(ctx, cmd)
	}
}

func getKustomizationFile(kusDir string) (string, error) {
	for _, path := range constants.KustomizeFilePaths {
		kPath := filepath.Join(kusDir, path)
		_, err := os.Stat(kPath)
		if err != nil {
			continue
		}
		return kPath, nil
	}
	return "", fmt.Errorf("cannot locate kustomization file from provided directory: %s", kusDir)
}

func (k Kustomize) mirror(kusDir string, fs TmpFS) error {
	kFile, err := getKustomizationFile(kusDir)
	if err != nil {
		return err
	}

	bytes, err := os.ReadFile(kFile)
	if err != nil {
		return err
	}

	if err := fs.WriteTo(kFile, bytes); err != nil {
		return err
	}

	kustomization := types.Kustomization{}

View on GitHub (pinned to a1189de023)

Solutions

  1. Verify the configured path points at a directory containing kustomization.yaml, kustomization.yml, or Kustomization
  2. Create or rename the kustomization file with the exact expected casing
  3. Check the expanded path (env templates) resolves to the intended directory
  4. If referencing a remote base, use a URL/path whose root still has a kustomization file

Example fix

// before
ls overlays/prod/    # only deployment.yaml, no kustomization.yaml
// after
# add overlays/prod/kustomization.yaml:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml
Defensive patterns

Strategy: validation

Validate before calling

for _, name := range []string{"kustomization.yaml","kustomization.yml","Kustomization"} {
    if fi, err := os.Stat(filepath.Join(kusDir, name)); err == nil && !fi.IsDir() {
        return nil // found
    }
}
return fmt.Errorf("no kustomization file in %s", kusDir)

Try / catch

if _, err := getKustomizationFile(dir); err != nil {
    return fmt.Errorf("skaffold render precondition failed for %s: %w", dir, err)
}

Prevention

When it happens

Trigger: Render/mirror invoked with k.rCfg.Kustomize.Paths pointing to a directory that contains no kustomization.yaml/yml/Kustomization file; path points to the wrong directory or file was deleted.

Common situations: Pointing skaffold.yaml at an overlays parent dir instead of the overlay dir; kustomization.yaml not committed / wrong filename casing (KUSTOMIZATION.YAML); path expanded to a directory that only contains resources.

Related errors


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