slimtoolkit/slim · error

image layer data source path doesnt exist - %s

Error message

image layer data source path doesnt exist - %s

What it means

After confirming the Source string is non-empty, Build checks that the path actually exists on the filesystem (fsutil.Exists). If the path is missing the build fails with this error naming the offending path. Layers must be materialized on disk before building.

Source

Thrown at pkg/imagebuilder/internalbuilder/engine.go:161

	log.Debug("DefaultSimpleBuilder.Build: config image")

	img, err := mutate.ConfigFile(img, imgConfig)
	if err != nil {
		return nil, err
	}

	var layersToAdd []v1.Layer

	for i, layerInfo := range options.Layers {
		log.Debugf("DefaultSimpleBuilder.Build: [%d] create image layer (type=%v source=%s)",
			i, layerInfo.Type, layerInfo.Source)

		if layerInfo.Source == "" {
			return nil, fmt.Errorf("empty image layer data source")
		}

		if !fsutil.Exists(layerInfo.Source) {
			return nil, fmt.Errorf("image layer data source path doesnt exist - %s", layerInfo.Source)
		}

		switch layerInfo.Type {
		case imagebuilder.TarSource:
			if !fsutil.IsRegularFile(layerInfo.Source) {
				return nil, fmt.Errorf("image layer data source path is not a file - %s", layerInfo.Source)
			}

			if !fsutil.IsTarFile(layerInfo.Source) {
				return nil, fmt.Errorf("image layer data source path is not a tar file - %s", layerInfo.Source)
			}

			layer, err := layerFromTar(layerInfo)
			if err != nil {
				return nil, err
			}

			layersToAdd = append(layersToAdd, layer)

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Verify the path exists before calling Build (os.Stat) and print absolute paths in errors
  2. Convert relative paths to absolute early (filepath.Abs) with a known base directory
  3. Ensure artifact-producing steps complete before the build step in CI pipelines
  4. Check that cleanup routines (defer os.RemoveAll) don't remove the source before Build

Example fix

// before
layers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: "app.tar"})
// after
abs, err := filepath.Abs("app.tar")
if err != nil { return err }
if _, err := os.Stat(abs); err != nil { return fmt.Errorf("layer source missing: %w", err) }
layers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: abs})
Defensive patterns

Strategy: validation

Validate before calling

for i, l := range opts.Layers {
    if _, err := os.Stat(l.Source); err != nil {
        return fmt.Errorf("layer %d source missing: %w", i, err)
    }
}

Prevention

When it happens

Trigger: Passing a LayerDataInfo.Source path that does not exist: deleted temp dirs, wrong working directory with relative paths, typoed paths, or artifacts not yet produced when Build is invoked.

Common situations: Building in CI where the tar artifact step failed silently or ran in a different stage/container; relative paths resolved against a different cwd; race where a temp file is cleaned up before Build runs.

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


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/9a57e66767f1bdeb. Report an issue: GitHub.