can1357/oh-my-pi · error · StatError
cannot read table of mounted file systems: {error}
Error message
cannot read table of mounted file systems: {error} What it means
This error from the stat builtin (crates/pi-builtins/src/stat.rs) means the utility could not read the mount table file (e.g. /etc/mtab, /proc/mounts) when running in file-system mode (-f), where it reports filesystem status instead of file status. It wraps the underlying I/O/parse error in the `error` field. It is only compiled on unix; on non-unix targets the variant is dead code.
Source
Thrown at crates/pi-builtins/src/stat.rs:142
-`%n`: file name
-`%s`: block size (for faster transfers)
-`%S`: fundamental block size (for block counts)
-`%t`: file system type in hex
-`%T`: file system type in human readable form
NOTE: your shell may have its own version of stat, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.";
#[derive(Debug, Error)]
enum StatError {
#[error("Invalid quoting style: {style}")]
InvalidQuotingStyle { style: String },
#[error("missing operand\nTry 'stat --help' for more information.")]
MissingOperand,
#[error("{directive}: invalid directive")]
InvalidDirective { directive: String },
#[error("cannot read table of mounted file systems: {error}")]
#[cfg_attr(not(unix), allow(dead_code, reason = "mount tables are unix-only"))]
CannotReadFilesystem { error: String },
#[error("using '-' to denote standard input does not work in file system mode")]
#[cfg_attr(not(unix), allow(dead_code, reason = "stdin filesystem mode is unix-only"))]
StdinFilesystemMode,
#[error("cannot read file system information for {file}: {error}")]
CannotReadFilesystemInfo { file: String, error: String },
#[error("cannot stat {file}: {error}")]
CannotStat { file: String, error: String },
}
mod options {
pub const DEREFERENCE: &str = "dereference";
pub const FILE_SYSTEM: &str = "file-system";
pub const FORMAT: &str = "format";
pub const PRINTF: &str = "printf";
pub const TERSE: &str = "terse";
pub const BSD_SHELL: &str = "bsd-shell";View on GitHub (pinned to 9690622007)
Solutions
- Check that the system's mount table file exists and is readable (e.g. `cat /proc/mounts` or `/etc/mtab`) and mount /proc if missing.
- Run without sandbox restrictions that block reading /proc or the mount table.
- Fall back to regular file mode (`stat <path>` without -f) which does not need the mount table.
- Inspect the wrapped `error` string for the concrete errno/parse failure and fix that specific cause.
Example fix
// before: stat in file-system mode inside a container without /proc stat --file-system /data // error: cannot read table of mounted file systems: No such file or directory // after: mount /proc or use plain file stat stat /data
Defensive patterns
Strategy: fallback
Validate before calling
const ok = await Bun.file('/proc/self/mounts').exists().catch(() => false) || await Bun.file('/etc/mtab').exists().catch(() => false);
if (!ok) console.warn('mount table unavailable: filesystem-mode stat will fail'); Try / catch
try {
await stat.run(['--file-system', path]);
} catch (err) {
if (String(err).includes('cannot read table of mounted file systems')) {
// fall back to plain file stat
await stat.run([path]);
} else throw err;
} Prevention
- Ensure /proc is mounted in containers and sandboxes.
- Prefer plain stat mode unless filesystem metadata is specifically needed.
- Check mount-table readability during environment provisioning.
When it happens
Trigger: Running stat in filesystem mode (`stat --file-system <path>`) when the code calls the routine that reads the mounted-filesystems table and that read or parse fails.
Common situations: Containers or sandboxes without /proc mounted (missing /proc/mounts), a corrupted or unusual /etc/mtab, permission restrictions from seccomp/AppArmor denying access to mount info, or exotic mount table formats the parser does not understand.
Related errors
- cannot read file system information for {file}: {error}
- cannot stat {0}: No such file or directory
- cannot stat {0}: Not a directory
- using '-' to denote standard input does not work in file sys
- cannot stat {file}: {error}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/06652a91dff28002.
Report an issue: GitHub.