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
- Pass the project directory, not a file: `ty check --project /path/to/project`
- Verify the target with `ls -ld <path>` to confirm it is a directory
- 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
- Always pass a directory containing pyproject.toml to --project, never a .py file
- Validate with `test -d "$PROJECT"` in shell wrappers before invoking ty
- Use `$(dirname "$file")` when you only have a file path
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
- Expected at least one path to search for Python files
- Can only write to stdout when formatting from stdin, but…
- client exited without proper shutdown sequence
- Content not correctly formatted
- could not find any tasks matching the given criteria
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)