astral-sh/ruff · error

Provided project path

Error message

Provided project path `{project}` is not a directory

What it means

ty's `run_check` resolves the project root from the `--project` CLI flag and requires it to be an existing directory. If the provided path exists but is not a directory (or otherwise fails `is_dir()`), it returns this anyhow error instead of proceeding.

Solutions

  1. Pass the project directory, not a file: `ty check --project /path/to/project`
  2. Verify the target with `ls -ld <path>` to confirm it is a directory
  3. If you have a file path, use its parent directory: `--project $(dirname script.py)`

Example fix

// before
ty check --project ./src/main.py
// after
ty check --project ./src
Defensive patterns

Strategy: validation

Validate before calling

import os, sys
project = sys.argv[sys.argv.index('--project')+1]
if not os.path.isdir(project):
    sys.exit(f"--project must be a directory, got: {project}")

Type guard

function is_dir(p: str) -> bool {
  try { return Deno.statSync(p).isDirectory; } catch { return false; }
}

Try / catch

match run_check(...) {
    Err(e) if e.to_string().contains("is not a directory") => {
        eprintln!("--project must point to a directory containing pyproject.toml");
        std::process::exit(2);
    }
    result => result,
}

Prevention

When it happens

Trigger: Running `ty check --project <path>` where `<path>` is a regular file, symlink to a file, socket, or otherwise not a directory on disk.

Common situations: Passing a Python file (e.g. `--project script.py`) instead of the project folder; typos that resolve to a file; scripts that forward a filename where a directory is expected.

Related errors


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

Appendix: source

Thrown at crates/ty/src/lib.rs:119

    let verbosity = args.verbosity.level();
    let _guard = setup_tracing(verbosity, args.color.unwrap_or_default())?;

    let printer = Printer::new(verbosity, args.no_progress);

    tracing::debug!("Version: {}", version::version());

    // The base path to which all CLI arguments are relative to.
    let cwd = current_directory()?;

    let project_path = args
        .project
        .as_ref()
        .map(|project| {
            if project.as_std_path().is_dir() {
                Ok(SystemPath::absolute(project, &cwd))
            } else {
                Err(anyhow!(
                    "Provided project path `{project}` is not a directory"
                ))
            }
        })
        .transpose()?
        .unwrap_or_else(|| cwd.clone());

    let check_paths: Vec<_> = args
        .paths
        .iter()
        .map(|path| SystemPath::absolute(path, &cwd))
        .collect();

    let mode = if args.fix {
        MainLoopMode::Fix(FixMode::ApplyFixes)
    } else if args.add_ignore {
        MainLoopMode::Fix(FixMode::AddIgnore)
    } else {

View on GitHub (pinned to 5bb508f594)