BurntSushi/ripgrep · error
walkdir: same_file_system option not supported on this platf
Error message
walkdir: same_file_system option not supported on this platform
What it means
device_num is implemented for unix (via MetadataExt::dev) and windows (via winapi_util volume serial number). The #[cfg(not(any(unix, windows)))] stub returns Err('walkdir: same_file_system option not supported on this platform'). It is hit when same_file_system traversal is enabled on a target with no device-number concept.
Source
Thrown at crates/ignore/src/walk.rs:2187
#[cfg(unix)]
fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> {
use std::os::unix::fs::MetadataExt;
path.as_ref().metadata().map(|md| md.dev())
}
#[cfg(windows)]
fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> {
use winapi_util::{Handle, file};
let h = Handle::from_path_any(path)?;
file::information(h).map(|info| info.volume_serial_number())
}
#[cfg(not(any(unix, windows)))]
fn device_num<P: AsRef<Path>>(_: P) -> io::Result<u64> {
Err(io::Error::new(
io::ErrorKind::Other,
"walkdir: same_file_system option not supported on this platform",
))
}
#[cfg(test)]
mod tests {
use std::ffi::OsStr;
use std::fs::{self, File};
use std::io::Write;
use std::path::Path;
use std::sync::{Arc, Mutex};
use super::{DirEntry, WalkBuilder, WalkState};
use crate::tests::TempDir;
fn wfile<P: AsRef<Path>>(path: P, contents: &str) {
let mut file = File::create(path).unwrap();View on GitHub (pinned to 3fce3b5bb0)
Solutions
- Disable same_file_system on the unsupported target (do not call WalkBuilder::same_file_system(true)).
- Target a supported platform (unix or windows) if you need same-device traversal semantics.
- Detect the target at build time and gate the same_file_system option behind cfg(any(unix, windows)).
Example fix
// before let mut wb = WalkBuilder::new(root); wb.same_file_system(true); // errors on wasm // after let mut wb = WalkBuilder::new(root); #[cfg(any(unix, windows))] wb.same_file_system(true);
Defensive patterns
Strategy: validation
Validate before calling
const SAME_FS_SUPPORTED: bool = cfg!(any(unix, windows)); // only set same_file_system when true: // #[cfg(any(unix, windows))] wb.same_file_system(true);
Try / catch
if cfg!(not(any(unix, windows))) {
eprintln!("same_file_system not supported here");
return;
} Prevention
- Do not enable same_file_system on non-unix/non-windows targets.
- Gate the option behind cfg(any(unix, windows)).
- Document platform limits for same-device traversal in your tool's docs.
When it happens
Trigger: Enabling WalkBuilder::same_file_system(true) (or the equivalent flag) on a non-unix/non-windows target; the walk attempts device_num to enforce the same-device constraint and gets this error.
Common situations: Cross-compiling ripgrep/ignore tooling to wasm32 with --files-with-matches and same_file_system enabled by config; a default config that turns on same_file_system unconditionally on a target that cannot support it.
Related errors
AI-assisted analysis of BurntSushi/ripgrep@3fce3b5bb0 (2026-08-06).
Data as JSON: /data/errors/62f7c086ab03e878.json.
Report an issue: GitHub.