twpayne/chezmoi · error
%s: unsupported mode %o
Error message
%s: unsupported mode %o
What it means
archiveReaderSystem (internal/chezmoi/archivereadersystem.go:69) errors with "%s: unsupported mode %o" when an archive entry is neither a directory, regular file, nor symlink — i.e. its mode type bits match no supported entry kind.
Source
Thrown at internal/chezmoi/archivereadersystem.go:69
if name.IsEmpty() {
return nil
}
nameAbsPath := options.RootAbsPath.Join(name)
s.fileInfos[nameAbsPath] = fileInfo
switch {
case fileInfo.IsDir():
// Do nothing.
case fileInfo.Mode()&fs.ModeType == 0:
contents, err := io.ReadAll(r)
if err != nil {
return fmt.Errorf("%s: %w", name, err)
}
s.contents[nameAbsPath] = contents
case fileInfo.Mode()&fs.ModeType == fs.ModeSymlink:
s.linkname[nameAbsPath] = linkname
default:
return fmt.Errorf("%s: unsupported mode %o", name, fileInfo.Mode()&fs.ModeType)
}
return nil
}); err != nil {
return nil, err
}
return s, nil
}
// FileInfos returns s's fs.FileInfos.
func (s *ArchiveReaderSystem) FileInfos() map[AbsPath]fs.FileInfo {
return s.fileInfos
}
// Lstat implements System.Lstat.
func (s *ArchiveReaderSystem) Lstat(filename AbsPath) (fs.FileInfo, error) {
fileInfo, ok := s.fileInfos[filename]
if !ok {View on GitHub (pinned to f901167e46)
Solutions
- Rebuild the archive excluding special files (exclude /dev, sockets, fifos).
- Convert special entries to regular files before archiving.
- Use a mainstream archiver and standard formats (tar/pax) so modes are sane.
Example fix
# before tar -cf dump.tar /var/run/mypipe /dev/sda # after tar --exclude='/dev/*' --exclude='*.sock' --exclude='*.pipe' -cf dump.tar myfiles/
Defensive patterns
Strategy: validation
Validate before calling
// Skip entries with unsupported mode types before processing
if m := fi.Mode() & fs.ModeType; m != 0 && m != fs.ModeDir && m != fs.ModeSymlink {
return fmt.Errorf("skipping special entry %s mode %o", name, m)
} Prevention
- Exclude /dev, sockets, and fifos when creating archives.
- Use tar/pax formats and mainstream archivers.
- Audit archive contents for special file types before import.
When it happens
Trigger: WalkFile over an archive containing entries with mode types like named pipes, devices, or sockets.
Common situations: Archives built from /dev or containing fifos/sockets; archives produced by tools that preserve special file types; corruption flipping mode bits.
Related errors
- %s: unsupported typeflag '%c'
- %s: unsupported file mode %o
- %s: unknown archive format
- %s: %w
- %s: unsupported mode %o
AI-assisted analysis of twpayne/chezmoi@f901167e46 (2026-09-01).
Data as JSON: /api/errors/8fbcaf1b69be9027.
Report an issue: GitHub.