dagger/dagger · error

copy changed paths: %w

Error message

copy changed paths: %w

What it means

This error wraps failure of the copier run that copies each changed path (added/modified entries of the changeset) from the diff snapshot into the target directory's mounted snapshot, using CopyDirContents and ReplaceExisting. It is the copy-loop stage of applyChangesToSnapshot.

Source

Thrown at core/directory.go:3180

		if err := removeChangesetPaths(root, targetDir, paths.Removed); err != nil {
			return err
		}

		if diffSnapshot != nil {
			err = MountRef(ctx, diffSnapshot, func(srcRoot string, srcMnt *mount.Mount) error {
				return copier.Copy(ctx,
					layercopy.Mount{Root: srcRoot, Mount: srcMnt},
					diffPath,
					targetDir,
					layercopy.CopyOptions{
						CopyDirContents: true,
						ReplaceExisting: true,
					},
				)
			}, mountRefAsReadOnly)
			if err != nil {
				return fmt.Errorf("copy changed paths: %w", err)
			}
		}

		if err := mkdirChangesetAddedDirs(ctx, copier, targetDir, paths); err != nil {
			return err
		}

		usage, err = copier.Usage()
		return err
	})
	if err != nil {
		return nil, err
	}

	ref, err := newRef.CommitWithUsage(ctx, usage)
	if err != nil {
		return nil, fmt.Errorf("commit changed directory: %w", err)
	}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Inspect the wrapped cause to identify the failing path or mount; verify that path exists in the before/after directories.
  2. Rerun the operation; transient IO/context errors typically resolve on retry.
  3. Check engine disk space and permissions on the cache volume.
  4. If a specific path is consistently failing, recreate the changeset for that path explicitly (withNewFile/withDirectory) to bypass the diff path.

Example fix

// before
if err := copyFn(...); err != nil {
	return fmt.Errorf("copy changed paths: %w", err)
}
// after
if err := copyFn(...); err != nil {
	if errors.Is(err, fs.ErrNotExist) {
		return fmt.Errorf("copy changed paths: path vanished between diff and apply: %w", err)
	}
	return fmt.Errorf("copy changed paths: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify changed paths still exist in the after directory before applying
for _, p := range changedPaths { if _, err := afterDir.File(p).ID(ctx); err != nil { return fmt.Errorf("path missing: %s", p) } }

Try / catch

out, err := applyChanges(); if err != nil { if errors.Is(err, fs.ErrNotExist) { /* rebuild the changeset */ } return err }

Prevention

When it happens

Trigger: Applying a Directory changeset where the copy of a changed path fails: source path missing from the diff snapshot, cross-device or permission errors during copy, interrupted context, or mountRefAsReadOnly mount setup failure.

Common situations: Changes referencing paths removed between diff computation and application; filesystem permission anomalies; large trees hitting timeouts or ENOSPC.

Related errors


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