hashicorp/packer · error
Unable to get fileinfo for %s: %s
Error message
Unable to get fileinfo for %s: %s
What it means
createTarArchive opened an artifact file but file.Stat() failed, so tar header creation cannot proceed. The post-processor needs the file's size/mode/timestamps to build a tar header; without stat metadata it aborts and PostProcess reports 'Error creating tar'.
Source
Thrown at post-processor/compress/post-processor.go:390
}
_ = gzipWriter.SetConcurrency(500000, runtime.GOMAXPROCS(-1))
return gzipWriter, nil
}
func createTarArchive(files []string, output io.WriteCloser) error {
archive := tar.NewWriter(output)
defer archive.Close()
for _, path := range files {
file, err := os.Open(path)
if err != nil {
return fmt.Errorf("Unable to read file %s: %s", path, err)
}
defer file.Close()
fi, err := file.Stat()
if err != nil {
return fmt.Errorf("Unable to get fileinfo for %s: %s", path, err)
}
header, err := tar.FileInfoHeader(fi, path)
if err != nil {
return fmt.Errorf("Failed to create tar header for %s: %s", path, err)
}
// workaround for archive format on go >=1.10
setHeaderFormat(header)
if err := archive.WriteHeader(header); err != nil {
return fmt.Errorf("Failed to write tar header for %s: %s", path, err)
}
if _, err := io.Copy(archive, file); err != nil {
return fmt.Errorf("Failed to copy %s data to archive: %s", path, err)
}
}View on GitHub (pinned to eb36e3c3e4)
Solutions
- Re-run the build; this is frequently a race with file deletion
- Check the filesystem backing the artifact (dmesg / mount health) for I/O errors
- Avoid external cleanup processes touching the output directory during the build
- Use a local output directory instead of a network mount
Defensive patterns
Strategy: retry
Validate before calling
// pre-flight: confirm stat works on all artifact files (detects flaky mounts)
for _, p := range artifact.Files() {
if _, err := os.Stat(p); err != nil {
return fmt.Errorf("stat unavailable for %s: %w", p, err)
}
} Try / catch
// Go: stat races are transient; retry the post-process once
artifact, _, _, err := pp.PostProcess(ctx, ui, artifact)
if err != nil && strings.Contains(err.Error(), "Unable to get fileinfo") {
time.Sleep(time.Second)
return pp.PostProcess(ctx, ui, artifact)
} Prevention
- Prefer local filesystems over NFS/SMB for build outputs
- Stop external cleanup jobs that touch output directories during builds
- Check filesystem health (dmesg) if stat errors recur
- Re-run the pipeline when errors are sporadic
When it happens
Trigger: createTarArchive calls file.Stat() on a successfully opened file and the OS returns an error — rare, usually indicating the file was deleted between Open and Stat, or an underlying filesystem I/O error.
Common situations: Files on flaky network mounts (NFS/SMB) whose metadata lookups fail; concurrent cleanup jobs removing artifacts during packaging; exotic filesystems with unreliable stat support.
Related errors
- Unable to read file %s: %s
- unable to create dir: %s
- unable to create file %s: %s
- unable to open file %s: %s
- Error creating tar: %s
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/b5646d5c12cfacb5.
Report an issue: GitHub.