muesli/duf · critical
reading mountinfo %q: %w
Error message
reading mountinfo %q: %w
What it means
The mounts function on Linux reads /proc/self/mountinfo via readLines. If that read fails (missing file, permission problem, or I/O error), it wraps the cause as "reading mountinfo %q: %w". The mount table is essential input, so the error aborts mount enumeration.
Source
Thrown at mounts_linux.go:58
// (9) mount source: filesystem specific information or "none".
mountinfoMountSource = 9
// (10) super options: per super block options.
mountinfoSuperOptions = 10
)
// Stat returns the mountpoint's stat information.
func (m *Mount) Stat() unix.Statfs_t {
return m.Metadata.(unix.Statfs_t)
}
func mounts() ([]Mount, []string, error) {
var warnings []string
filename := "/proc/self/mountinfo"
lines, err := readLines(filename)
if err != nil {
// wrapcheck: add context to the error.
return nil, nil, fmt.Errorf("reading mountinfo %q: %w", filename, err)
}
ret := make([]Mount, 0, len(lines))
for _, line := range lines {
nb, fields := parseMountInfoLine(line)
if nb == 0 {
continue
}
// if the number of fields does not match the structure of mountinfo,
// emit a warning and ignore the line.
if nb < 10 || nb > 11 {
warnings = append(warnings, fmt.Sprintf("found invalid mountinfo line: %s", line))
continue
}
// blockDeviceID := fields[mountinfoMountID]
mountPoint := fields[mountinfoMountPoint]View on GitHub (pinned to 4636deb4a7)
Solutions
- Ensure /proc is mounted in the environment (e.g. mount -t proc proc /proc in containers).
- Check the wrapped %w error to see the underlying cause (ENOENT vs EACCES).
- Run the program with sufficient permissions or outside the restricting sandbox.
- Fall back to a different mount enumeration API if available in your environment.
Example fix
// docker run without proc $ docker run --rm app // after $ docker run --rm -v /proc:/proc:ro app # or just ensure default /proc is present
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := os.Stat("/proc/self/mountinfo"); err != nil {
log.Fatal("/proc is not available: ", err)
} Try / catch
mounts, warns, err := mounts()
if err != nil {
if errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrNotExist) {
log.Fatal("procfs unavailable: ", err)
}
} Prevention
- Ensure /proc is mounted when running in containers.
- Check sandbox/seccomp policies allow reading /proc/self/mountinfo.
- Prefer running the tool in an environment with standard procfs access.
When it happens
Trigger: readLines("/proc/self/mountinfo") returns an error: the proc filesystem is not mounted, the file is unreadable due to sandboxing/permissions, or a transient I/O error occurs.
Common situations: Running inside minimal containers without /proc mounted, restricted sandboxes (seccomp/AppArmor) blocking /proc access, or unusual environments where procfs is hidden.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- error formatting the json output: %s
- unknown style option: %s
- unknown device group: %s
- error parsing avail-threshold: invalid option '%s'
- error parsing usage-threshold: invalid option '%s'
AI-assisted analysis of muesli/duf@4636deb4a7 (2026-09-06).
Data as JSON: /api/errors/6f41ee0ae87efca0.
Report an issue: GitHub.