uutils/coreutils · error · io::Error

Is a directory

Error message

Is a directory

What it means

During checksum validation (`get_file_to_check`), opening a file that turns out to be a directory produces an explicit `io::ErrorKind::IsADirectory` error printed as "Is a directory", the open is counted as a failed open, and `LineCheckError::FileIsDirectory` is returned so the line of the checksum file is treated as failed.

Source

Thrown at src/uucore/src/lib/features/checksum/validate.rs:570

                FileChecksumResult::CantOpen,
                opts.verbose,
            );
        };
        let print_error = |err: io::Error| {
            show!(err.map_err_context(|| {
                locale_aware_escape_name(filename, QuotingStyle::SHELL_ESCAPE)
                    // This is non destructive thanks to the escaping
                    .to_string_lossy()
                    .to_string()
            }));
        };
        match File::open(filename) {
            Ok(f) => {
                if f.metadata()
                    .map_err(|_| LineCheckError::CantOpenFile)?
                    .is_dir()
                {
                    print_error(io::Error::new(
                        io::ErrorKind::IsADirectory,
                        "Is a directory",
                    ));
                    // also regarded as a failed open
                    failed_open();
                    Err(LineCheckError::FileIsDirectory)
                } else {
                    Ok(Box::new(f))
                }
            }
            Err(err) => {
                if !opts.ignore_missing {
                    // yes, we have both stderr and stdout here
                    print_error(err);
                    failed_open();
                }
                // we could not open the file but we want to continue
                Err(LineCheckError::FileNotFound)

View on GitHub (pinned to 85295bbf78)

Solutions

  1. Remove the directory entry from the checksum file
  2. Re-generate the checksum file so it contains only regular files
  3. Verify the expected file wasn't replaced by a directory

Example fix

# before
sha256sum * > checksums.sha256   # may include directories
# after
find . -type f -exec sha256sum {} + > checksums.sha256
Defensive patterns

Strategy: validation

Validate before calling

let md = std::fs::metadata(path)?;
if md.is_dir() {
    eprintln!("skipping directory: {}", path.display());
} else {
    validate_checksum(path)?;
}

Type guard

fn is_regular_file(p: &Path) -> bool {
    std::fs::metadata(p).map(|m| m.is_file()).unwrap_or(false)
}

Try / catch

match validate_checksum(path) {
    Err(e) if e.to_string() == "Is a directory" => skip_entry(path),
    other => other?,
}

Prevention

When it happens

Trigger: A checksum file lists a path that is actually a directory; `compute_and_check_digest_from_file` hits it while iterating listed paths and calls `File::open(filename)`, which succeeds on some platforms, then metadata shows `is_dir()`.

Common situations: Checksum manifests generated with wildcards that matched directories, hand-edited .sha256/.md5 files, or renamed files replaced by directories of the same name.

Related errors


AI-assisted analysis of uutils/coreutils@85295bbf78 (2026-08-31). Data as JSON: /api/errors/f661ca636c1c0101. Report an issue: GitHub.