rust-lang/rust-clippy · error

error reading

Error message

error reading `{}`: {e}

What it means

Emitted in load_conf_file after a clippy.toml/.clippy.toml was located but could not be read or loaded as a source file. sess.source_map().load_file fails on I/O errors such as unreadable permissions, a path that is not a regular file, or non-UTF-8 content. The {e} placeholder carries the underlying std::io error; when this fires the discovered config file is effectively unusable and clippy proceeds without it.

Solutions

  1. Check file permissions on the config file and ensure the running user can read it
  2. Confirm the file is a regular UTF-8 encoded file and not a directory or symlink to a missing target
  3. Fix the underlying I/O issue reported by {e} (disk, mount, path length) and rerun clippy
  4. Move or recreate the config file at a readable location and set CLIPPY_CONF_DIR to it
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at clippy_config/src/conf.rs:911 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rust-lang/rust-clippy@13aece1138 (2026-09-07). Data as JSON: /api/errors/87b465082fb589cc. Report an issue: GitHub.

Appendix: source

Thrown at clippy_config/src/conf.rs:911

                    if fs::metadata(loaded_path).is_ok_and(|x| x.is_file()) {
                        // Warn if `.clippy.toml` and `clippy.toml` exist
                        sess.dcx().warn(format!(
                            "using config file `{}`, `{}` will be ignored",
                            loaded_path.display(),
                            config_path.display(),
                        ));
                    }
                } else {
                    match sess.source_map().load_file(&config_path) {
                        Ok(src) => loaded_config = Some((config_path, src)),
                        Err(e)
                            if matches!(
                                e.kind(),
                                io::ErrorKind::NotFound | io::ErrorKind::IsADirectory | io::ErrorKind::NotADirectory
                            ) => {},
                        Err(e) => {
                            sess.dcx()
                                .err(format!("error reading `{}`: {e}", config_path.display()));
                            return None;
                        },
                    }
                }
            }
        }

        // Don't mention config files in parent directories.
        if let Some((_, src)) = loaded_config {
            return Some(src);
        }

        // If the current directory has no parent, we're done searching.
        if !current.pop() {
            return None;
        }
    }
}

View on GitHub (pinned to 13aece1138)