astral-sh/ruff · error · anyhow::Error

No files found under the given path

Error message

No files found under the given path

What it means

The `ruff show-settings` command resolves settings for a file under the given path; it requires at least one resolved file to determine which file's effective settings to display. If the provided path yields no files (after exclusion), the command bails with this error.

Solutions

  1. Pass a path that contains at least one (non-excluded) Python file.
  2. Check your `exclude`/`extend-exclude`/gitignore settings to confirm the target files are not being filtered out.
  3. Verify the path is spelled correctly relative to the current working directory.

Example fix

// before
ruff show-settings ./empty-dir
// after
ruff show-settings ./src
Defensive patterns

Strategy: validation

Validate before calling

# Verify the path yields at least one non-excluded Python file first:
import subprocess
out = subprocess.run(['ruff', 'check', path, '--no-cache'], capture_output=True, text=True)
if 'No Python files found' in out.stdout + out.stderr:
    raise SystemExit(f'{path} matches no lintable files; show-settings would fail')

Prevention

When it happens

Trigger: Running `ruff show-settings <path>` where the path matches no Python files — the directory is empty, all files are excluded by configuration, the glob matches nothing, or the path points at ignored directories.

Common situations: Typoed or wrong directory paths; running show-settings on directories whose contents are excluded via `exclude`/`extend-exclude` settings; empty repos or paths filtered out by respect-gitignore.

Related errors


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/fe4ceda882460435. Report an issue: GitHub.

Appendix: source

Thrown at crates/ruff/src/commands/show_settings.rs:29

/// Print the user-facing configuration settings.
pub(crate) fn show_settings(
    files: &[PathBuf],
    pyproject_config: &PyprojectConfig,
    config_arguments: &ConfigArguments,
    writer: &mut impl Write,
) -> Result<()> {
    // Collect all files in the hierarchy.
    let (paths, resolver) = project_files_in_path(files, pyproject_config, config_arguments)?;

    // Print the list of files.
    let Some(path) = paths
        .into_iter()
        .flatten()
        .map(ResolvedFile::into_path)
        .sorted_unstable()
        .next()
    else {
        bail!("No files found under the given path");
    };

    let (settings, config_path) = resolver.resolve_with_path(&path);

    writeln!(writer, "Resolved settings for: \"{}\"", path.display())?;
    if let Some(settings_path) = config_path {
        writeln!(writer, "Settings path: \"{}\"", settings_path.display())?;
    }
    write!(writer, "{settings}")?;

    Ok(())
}

View on GitHub (pinned to 26f38c119c)