dagger/dagger · error

copy changed paths

Error message

copy changed paths: %w

What it means

After mounting the diff snapshot read-only, applyContent copies the changed paths into the merge work tree via copier.Copy (ReplaceExisting, .git excluded); any failure inside that copy or the MountRef callback is wrapped as 'copy changed paths: <cause>'. This is the core content-transfer step of applying a changeset to a git merge workspace.

Solutions

  1. Read the wrapped cause for the concrete errno; free disk space if ENOSPC
  2. Retry the merge — the workspace is ephemeral and rebuilt from scratch each time
  3. Verify the diff snapshot contents (e.g. export it) to rule out corrupted cached layers
  4. Check mount support/permissions on the host (overlayfs, userns) if the MountRef step fails
  5. Update the engine; copy fallback and .git-exclusion filtering have had fixes

Example fix

// before
err = MountRef(ctx, diffRef, func(srcRoot string, srcMnt *mount.Mount) error {
	return copier.Copy(ctx, layercopy.Mount{Root: srcRoot, Mount: srcMnt}, diffPath, ws.dir, opts)
}, mountRefAsReadOnly)
if err != nil {
	return fmt.Errorf("copy changed paths: %w", err)
}
// after (caller-side: retry transient copy failures once)
err = MountRef(ctx, diffRef, func(srcRoot string, srcMnt *mount.Mount) error {
	return copier.Copy(ctx, layercopy.Mount{Root: srcRoot, Mount: srcMnt}, diffPath, ws.dir, opts)
}, mountRefAsReadOnly)
if err != nil && errors.Is(err, syscall.EIO) {
	err = retryMountAndCopy(ctx, diffRef, diffPath, ws.dir, opts)
}
if err != nil {
	return fmt.Errorf("copy changed paths: %w", err)
}
Defensive patterns

Strategy: retry

Validate before calling

// verify mount capability and free space before large merges
if err := checkOverlayMountSupport(); err != nil {
	return fmt.Errorf("host cannot mount diff snapshots: %w", err)
}
if free, _ := diskFree(engineCacheDir); free < requiredBytes {
	return fmt.Errorf("need %d bytes free for merge copy", requiredBytes)
}

Type guard

func isCopyChangedPathsError(err error) bool {
	return err != nil && strings.Contains(err.Error(), "copy changed paths:")
}

Try / catch

err := dag.Directory().Merge(...)
if err != nil {
	var serr syscall.Errno
	if isCopyChangedPathsError(err) && errors.As(err, &serr) && (errors.Is(err, syscall.ENOSPC) || errors.Is(err, syscall.EIO)) {
		// free space / rebuild snapshot, then retry once
	}
	return err
}

Prevention

When it happens

Trigger: copier.Copy from the mounted diff snapshot into the merge workspace fails — cross-device copy fallback errors, EACCES/EPERM on destination paths, ENOSPC on the overlay upperdir, I/O errors reading the source mount, or an error returned by the MountRef mount callback itself.

Common situations: Disk-full during large merges; read-only or corrupted overlay upperdir; symlink or permission edge cases in the diff snapshot; source mount busy (EBUSY) or unavailable; checksum/verification failure of cached blobs.

Related errors


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

Appendix: source

Thrown at core/changeset.go:1550

						ReplaceExisting: true,
						// Linking from the diff snapshot into the mounted
						// work tree crosses devices, so every attempt would
						// just fail into the copy fallback.
						DisableSourceHardlinks: true,
						// The diff snapshot can carry .git entries that
						// ComputePaths never reported: the stat-sensitive
						// differ flags files whose content is identical but
						// whose timestamps diverge across content-deduped
						// snapshots. Overlaying those onto the temporary
						// repository corrupts the merge.
						Filter: layercopy.Filter{
							Exclude: []string{".git"},
						},
					},
				)
			}, mountRefAsReadOnly)
			if err != nil {
				return fmt.Errorf("copy changed paths: %w", err)
			}
		}
	}

	if err := mkdirChangesetAddedDirs(ctx, copier, ws.dir, paths); err != nil {
		return err
	}
	return ws.touchAppliedPaths(paths)
}

// touchAppliedPaths bumps the mtime of every path the changeset wrote so git
// can see the change. Snapshot contents carry normalized timestamps and the
// copier preserves them, so a same-size edit can leave a file's mtime and
// size both identical to the index entry; with core.checkStat=minimal (see
// gitEphemeralConfig) git add would then skip re-hashing it and silently
// drop the change from the branch commit.
func (ws *gitMergeWorkspace) touchAppliedPaths(paths *ChangesetPaths) error {
	for _, p := range slices.Concat(paths.Added, paths.Modified) {

View on GitHub (pinned to 82ba2681db)