sharkdp/hexyl · error
' ' is a directory.
Error message
'{}' is a directory. What it means
b3sum throws this when the file argument passed via --file (or positional input) resolves to a directory rather than a regular file. File::open on a directory succeeds on Unix but reading fails, so the tool rejects it early with a clear message.
Solutions
- Pass a regular file path instead of a directory
- Use '-' to read from stdin instead of a path
- Glob the directory's files (e.g. `b3sum dir/*`) or use find -type f
- Check the path with `test -f "$path"` before invoking
Example fix
// before b3sum ./mydir // after b3sum ./mydir/file.bin b3sum ./mydir/*
Defensive patterns
Strategy: validation
Validate before calling
if [ -d "$path" ]; then echo "refusing: $path is a directory" >&2; exit 1; fi
Type guard
fn is_regular_file(p: &Path) -> bool { p.is_file() } Prevention
- Check path kind before passing to b3sum
- Use globs that expand to files only
- Prefer explicit '-' for stdin
When it happens
Trigger: Running `b3sum somedirectory` where the filename argument exists on disk and is_dir() returns true, or explicitly passing a directory path instead of a file or '-' for stdin.
Common situations: Shell tab-completion filling in a directory name; intending to hash all files in a folder but passing the folder itself; scripts that glob a path that matches a directory.
Related errors
- failed to parse `--skip` arg
- failed to parse `--length` arg
- anyhow!(e)
- block size argument must be positive
- can not use 'block(s)' as a unit to specify block size
AI-assisted analysis of sharkdp/hexyl@6ecc29b9c8 (2026-09-09).
Data as JSON: /api/errors/f0c1e9fd94c603ea.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:291
return print_color_table().map_err(|e| anyhow!(e));
}
if let Some(sh) = opt.completion {
let mut cmd = Opt::command();
let name = cmd.get_name().to_string();
generate(sh, &mut cmd, name, &mut io::stdout());
return Ok(());
}
let stdin = io::stdin();
let mut reader = match &opt.file {
Some(filename) => {
if filename.as_os_str() == "-" {
Input::Stdin(stdin.lock())
} else {
if filename.is_dir() {
bail!("'{}' is a directory.", filename.to_string_lossy());
}
let file = File::open(filename)?;
Input::File(file)
}
}
None => Input::Stdin(stdin.lock()),
};
if let Some(hex_number) = try_parse_as_hex_number(&opt.block_size) {
return hex_number
.map_err(|e| anyhow!(e))
.and_then(|x| {
PositiveI64::new(x).ok_or_else(|| anyhow!("block size argument must be positive"))
})
.map(|_| ());
}
let (num, unit) = extract_num_and_unit_from(&opt.block_size)?;View on GitHub (pinned to 6ecc29b9c8)