{"record":{"id":"f661ca636c1c0101","repo":"uutils/coreutils","slug":"is-a-directory","errorCode":null,"errorMessage":"Is a directory","messagePattern":"Is a directory","errorType":"console","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/uucore/src/lib/features/checksum/validate.rs","lineNumber":570,"sourceCode":"                FileChecksumResult::CantOpen,\n                opts.verbose,\n            );\n        };\n        let print_error = |err: io::Error| {\n            show!(err.map_err_context(|| {\n                locale_aware_escape_name(filename, QuotingStyle::SHELL_ESCAPE)\n                    // This is non destructive thanks to the escaping\n                    .to_string_lossy()\n                    .to_string()\n            }));\n        };\n        match File::open(filename) {\n            Ok(f) => {\n                if f.metadata()\n                    .map_err(|_| LineCheckError::CantOpenFile)?\n                    .is_dir()\n                {\n                    print_error(io::Error::new(\n                        io::ErrorKind::IsADirectory,\n                        \"Is a directory\",\n                    ));\n                    // also regarded as a failed open\n                    failed_open();\n                    Err(LineCheckError::FileIsDirectory)\n                } else {\n                    Ok(Box::new(f))\n                }\n            }\n            Err(err) => {\n                if !opts.ignore_missing {\n                    // yes, we have both stderr and stdout here\n                    print_error(err);\n                    failed_open();\n                }\n                // we could not open the file but we want to continue\n                Err(LineCheckError::FileNotFound)","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/uutils/coreutils/blob/92995feca29e324a7c559ede91db81c32d9f5d59/src/uucore/src/lib/features/checksum/validate.rs#L552-L588","documentation":"While validating a checksum file line, get_file_to_check opened the named path successfully but stat shows it is a directory, so no digest can be computed. The code prints an 'Is a directory' io error, counts it as a failed open, and returns LineCheckError::FileIsDirectory — the line is treated as a verification failure.","triggerScenarios":"Running `sha256sum -c` (or md5sum -c) where the checksum file lists a path that is actually a directory, e.g. a manually written checksum file or a generated one containing 'dir/' entries; also nested directories with a checksum file per directory (check mode) encountering directory names.","commonSituations":"Hand-maintained .sha256 files with directory names pasted in; tools generating manifest entries for directories by mistake; running checksum verification from the wrong working directory where the same name maps to a directory; with `--check` inside recursive setups.","solutions":["Remove or skip directory entries from the checksum file — checksums apply to regular files only.","Generate the manifest correctly: find . -type f -exec sha256sum {} + > file.sha256","Run find with -type d filtering or exclude directories when creating/verifying the list.","Check the path in the checksum file relative to your cwd; cd to the manifest's root directory before `sha256sum -c`."],"exampleFix":"# before: checksum file contains a directory line -> \"Is a directory\"\ngrep -v '/$' checksums.sha256 > checksums.files.sha256\n# after: regenerate from files only\nfind . -type f -exec sha256sum {} + > checksums.sha256\nsha256sum -c checksums.sha256","handlingStrategy":"validation","validationCode":"# Filter directory entries out of a checksum manifest before -c\nawk '$1 !~ /^[0-9a-fA-F]{32,}$/ {next} {print}' checksums.sha256 > clean.sha256\n# or generate correctly in the first place:\nfind . -type f -exec sha256sum {} + > checksums.sha256","typeGuard":"// Node: skip directories listed in a manifest\nconst st = fs.statSync(line.path, { throwIfNoEntry: false });\nif (!st || !st.isFile()) return; // skip dirs/missing entries","tryCatchPattern":"match compute_and_check_digest_from_file(...) {\n  Err(LineCheckError::FileIsDirectory) => {\n    eprintln!(\"skipping {}: it is a directory, not a file\", path);\n  }\n  Err(e) => return Err(e),\n  Ok(digest) => verify(digest),\n}","preventionTips":["Generate manifests with find -type f only","Never hand-edit checksum files with directory names","cd to the manifest root before sha256sum -c so paths resolve to files","Treat any listed directory in a manifest as a generation bug to fix upstream"],"tags":["checksum","directory","validation","sha256sum"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"92995feca29e324a7c559ede91db81c32d9f5d59","analyzedAt":"2026-09-20T12:39:35.476Z","contentChangedAt":"2026-09-20T12:39:35.476Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}