docker/compose · error
adding files to tar: %w
Error message
adding files to tar: %w
What it means
tarArchive runs ArchiveBuilder in a goroutine writing into an io.Pipe. If collecting/walking/writing entries fails (any of errors 103-111), the pipe is closed with 'adding files to tar: %w', which surfaces on the reading side — typically as the Untar/put-archive call failing with this message for every container being synced.
Source
Thrown at internal/sync/tar.go:327
info: info,
header: header,
})
return nil
})
if err != nil {
return nil, err
}
return result, nil
}
func tarArchive(ops []PathMapping) io.ReadCloser {
pr, pw := io.Pipe()
go func() {
ab := NewArchiveBuilder(pw)
err := ab.ArchivePathsIfExist(ops)
if err != nil {
_ = pw.CloseWithError(fmt.Errorf("adding files to tar: %w", err))
} else {
// propagate errors from the TarWriter::Close() because it performs a final
// Flush() and any errors mean the tar is invalid
if err := ab.Close(); err != nil {
_ = pw.CloseWithError(fmt.Errorf("closing tar: %w", err))
} else {
_ = pw.Close()
}
}
}()
return pr
}
// Dedupe the entries with last-entry-wins semantics.
func dedupeEntries(entries []archiveEntry) []archiveEntry {
seenIndex := make(map[string]int, len(entries))
result := make([]archiveEntry, 0, len(entries))
for i, entry := range entries {View on GitHub (pinned to ddc4b044b6)
Solutions
- Unwrap the %w — the inner error is one of errors 103-111 and names the real host-side problem; fix that first
- Check whether the named host tree was mid-rewrite (build running) and re-sync when idle
- Fix local permissions on the sync root (see 103/110)
- Do not restart containers in response to this error appearing everywhere at once — it is a local-side failure
Defensive patterns
Strategy: try-catch
Validate before calling
// validate the archive can be built before syncing to any container (dry-run into io.Discard)
if err := NewArchiveBuilder(io.Discard).ArchivePathsIfExist(paths); err != nil { return err } Try / catch
// on 'adding files to tar', unwrap the inner error (one of errors 103-111), fix the named host path, then retry — do not touch the containers
Prevention
- Dry-run archive builds in watch tooling before fan-out
- Keep synced trees free of unreadable/volatile files
When it happens
Trigger: ArchivePathsIfExist returning an error in the producer goroutine: unreadable paths (103/110), vanished or mid-write files (104-109), or relative-path computation failures (111). The message appears on the consumer side of the pipe, often for all 16 parallel container copies at once.
Common situations: compose watch failing on all replicas simultaneously with the same wrap — the tell that the local archive build, not the containers, is broken; usually triggered by source-tree churn or permissions.
Related errors
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/bb8c1892efac0241.
Report an issue: GitHub.