{"record":{"id":"06652a91dff28002","repo":"can1357/oh-my-pi","slug":"cannot-read-table-of-mounted-file-systems-error","errorCode":null,"errorMessage":"cannot read table of mounted file systems: {error}","messagePattern":"cannot read table of mounted file systems: (.+?)","errorType":"error_code","errorClass":"StatError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/stat.rs","lineNumber":142,"sourceCode":"-`%n`: file name\n-`%s`: block size (for faster transfers)\n-`%S`: fundamental block size (for block counts)\n-`%t`: file system type in hex\n-`%T`: file system type in human readable form\n\nNOTE: your shell may have its own version of stat, which usually supersedes\nthe version described here.  Please refer to your shell's documentation\nfor details about the options it supports.\";\n\n\t#[derive(Debug, Error)]\n\tenum StatError {\n\t\t#[error(\"Invalid quoting style: {style}\")]\n\t\tInvalidQuotingStyle { style: String },\n\t\t#[error(\"missing operand\\nTry 'stat --help' for more information.\")]\n\t\tMissingOperand,\n\t\t#[error(\"{directive}: invalid directive\")]\n\t\tInvalidDirective { directive: String },\n\t\t#[error(\"cannot read table of mounted file systems: {error}\")]\n\t\t#[cfg_attr(not(unix), allow(dead_code, reason = \"mount tables are unix-only\"))]\n\t\tCannotReadFilesystem { error: String },\n\t\t#[error(\"using '-' to denote standard input does not work in file system mode\")]\n\t\t#[cfg_attr(not(unix), allow(dead_code, reason = \"stdin filesystem mode is unix-only\"))]\n\t\tStdinFilesystemMode,\n\t\t#[error(\"cannot read file system information for {file}: {error}\")]\n\t\tCannotReadFilesystemInfo { file: String, error: String },\n\t\t#[error(\"cannot stat {file}: {error}\")]\n\t\tCannotStat { file: String, error: String },\n\t}\n\n\tmod options {\n\t\tpub const DEREFERENCE: &str = \"dereference\";\n\t\tpub const FILE_SYSTEM: &str = \"file-system\";\n\t\tpub const FORMAT: &str = \"format\";\n\t\tpub const PRINTF: &str = \"printf\";\n\t\tpub const TERSE: &str = \"terse\";\n\t\tpub const BSD_SHELL: &str = \"bsd-shell\";","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/stat.rs#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: stat in file-system mode inside a container without /proc\nstat --file-system /data\n// error: cannot read table of mounted file systems: No such file or directory\n\n// after: mount /proc or use plain file stat\nstat /data","handlingStrategy":"fallback","validationCode":"const ok = await Bun.file('/proc/self/mounts').exists().catch(() => false) || await Bun.file('/etc/mtab').exists().catch(() => false);\nif (!ok) console.warn('mount table unavailable: filesystem-mode stat will fail');","typeGuard":null,"tryCatchPattern":"try {\n  await stat.run(['--file-system', path]);\n} catch (err) {\n  if (String(err).includes('cannot read table of mounted file systems')) {\n    // fall back to plain file stat\n    await stat.run([path]);\n  } else throw err;\n}","preventionTips":["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."],"tags":["filesystem","unix","mount-table","stat"],"backgroundTag":"mount-table-unreadable","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}