{"record":{"id":"f0c1e9fd94c603ea","repo":"sharkdp/hexyl","slug":"is-a-directory","errorCode":null,"errorMessage":"'{}' is a directory.","messagePattern":"'(.+?)' is a directory\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":291,"sourceCode":"        return print_color_table().map_err(|e| anyhow!(e));\n    }\n\n    if let Some(sh) = opt.completion {\n        let mut cmd = Opt::command();\n        let name = cmd.get_name().to_string();\n        generate(sh, &mut cmd, name, &mut io::stdout());\n        return Ok(());\n    }\n\n    let stdin = io::stdin();\n\n    let mut reader = match &opt.file {\n        Some(filename) => {\n            if filename.as_os_str() == \"-\" {\n                Input::Stdin(stdin.lock())\n            } else {\n                if filename.is_dir() {\n                    bail!(\"'{}' is a directory.\", filename.to_string_lossy());\n                }\n                let file = File::open(filename)?;\n\n                Input::File(file)\n            }\n        }\n        None => Input::Stdin(stdin.lock()),\n    };\n\n    if let Some(hex_number) = try_parse_as_hex_number(&opt.block_size) {\n        return hex_number\n            .map_err(|e| anyhow!(e))\n            .and_then(|x| {\n                PositiveI64::new(x).ok_or_else(|| anyhow!(\"block size argument must be positive\"))\n            })\n            .map(|_| ());\n    }\n    let (num, unit) = extract_num_and_unit_from(&opt.block_size)?;","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/sharkdp/hexyl/blob/6ecc29b9c8c84d08a7e860f7f69c22b113b480ea/src/main.rs#L273-L309","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nb3sum ./mydir\n// after\nb3sum ./mydir/file.bin\nb3sum ./mydir/*","handlingStrategy":"validation","validationCode":"if [ -d \"$path\" ]; then echo \"refusing: $path is a directory\" >&2; exit 1; fi","typeGuard":"fn is_regular_file(p: &Path) -> bool { p.is_file() }","tryCatchPattern":null,"preventionTips":["Check path kind before passing to b3sum","Use globs that expand to files only","Prefer explicit '-' for stdin"],"tags":["cli","filesystem","invalid-argument"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"6ecc29b9c8c84d08a7e860f7f69c22b113b480ea","analyzedAt":"2026-09-09T22:34:15.450Z","contentChangedAt":"2026-09-09T22:34:15.450Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}