dagger/dagger · error

container directory lazy: missing mounted directory snapshot

Error message

container directory lazy: missing mounted directory snapshot for %s

What it means

When lazily materializing a container-mounted directory, Dagger needs the directory's on-disk snapshot to mount it and read the requested subpath. If the Directory result has a path but its Snapshot (the committed content-snapshot reference) is absent or nil, evaluation cannot proceed and this error names the mount target. It indicates a partially-materialized directory result, usually after persisted-state replay.

Source

Thrown at core/container.go:3312

				}
				dir.Platform = detached.Platform
				dir.Services = slices.Clone(detached.Services)
				if dirPath, ok := detached.Dir.Peek(); ok {
					dir.Dir.setValue(dirPath)
				}
				if snapshot, ok := detached.Snapshot.Peek(); ok && snapshot != nil {
					dir.Snapshot.setValue(snapshot)
				}
				dir.Lazy = nil
				return nil
			}
			mountedDirPath, ok := mountedDir.Dir.Peek()
			if !ok {
				return fmt.Errorf("container directory lazy: missing mounted directory path for %s", mnt.Target)
			}
			mountedSnapshot, ok := mountedDir.Snapshot.Peek()
			if !ok || mountedSnapshot == nil {
				return fmt.Errorf("container directory lazy: missing mounted directory snapshot for %s", mnt.Target)
			}
			finalDir := path.Join(mountedDirPath, subpath)
			if err := MountRef(ctx, mountedSnapshot, func(root string, _ *mount.Mount) error {
				resolvedPath, err := containerdfs.RootPath(root, finalDir)
				if err != nil {
					return err
				}
				info, err := os.Lstat(resolvedPath)
				if err != nil {
					return TrimErrPathPrefix(err, root)
				}
				if !info.IsDir() {
					return notADirectoryError{fmt.Errorf("path %s is a file, not a directory", lazy.Path)}
				}
				return nil
			}); err != nil {
				return RestoreErrPath(err, lazy.Path)
			}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Force full evaluation (including snapshot) of the mounted source directory before consuming the container directory, e.g. copy/export it first
  2. Re-run the pipeline in a fresh session to rebuild and re-snapshot the directory
  3. Prune/restart the engine cache to remove incomplete persisted results
  4. Update dagger CLI+engine together; report a core lazy-persistence bug if it reproduces
Defensive patterns

Strategy: validation

Validate before calling

// Force snapshot materialization by touching the directory before use
if _, err := srcDir.Entries(ctx); err != nil { return err }

Try / catch

d, err := ctr.Directory(ctx, target)
if err != nil && strings.Contains(err.Error(), "missing mounted directory snapshot") {
	// re-snapshot the source directory (export/import round-trip) and retry
}

Prevention

When it happens

Trigger: Reading container.directory(target) or its contents where the withMountedDirectory source directory was restored from cache with Dir set but Snapshot uncomputed — e.g. the source dir was cloned/peeked without ever being snapshotted in this engine session.

Common situations: Cached module runs across engine restarts; interrupted/failed snapshotting of the source directory; engine cache corruption or version skew after upgrade.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/ab7f65b55558595e. Report an issue: GitHub.