astral-sh/ruff · error
project directory `{project_path}` does not contain a base n
Error message
project directory `{project_path}` does not contain a base name What it means
`Task::new` derives each eval task's display name from `project_path.file_name()`; on all platforms `file_name()` returns None only for degenerate paths (`/`, `.`, or paths ending in `..`). Since the path here is the temp copy of a truth fixture directory, this is an internal harness invariant over the truth tree layout rather than a normal user-input error.
Source
Thrown at crates/ty_completion_eval/src/main.rs:277
db: ProjectDatabase,
dir: SystemPathBuf,
name: String,
cursor: Cursor,
settings: ty_ide::CompletionSettings,
}
impl Task {
/// Create a new task for the Python project at `project_path`.
///
/// `truth` should correspond to the completion configuration and the
/// expected answer for completions at the given `cursor` position.
fn new(
project_path: &SystemPath,
truth: &CompletionTruth,
cursor: Cursor,
) -> anyhow::Result<Task> {
let name = project_path.file_name().ok_or_else(|| {
anyhow::anyhow!("project directory `{project_path}` does not contain a base name")
})?;
let system = OsSystem::new(project_path);
let mut project_metadata = ProjectMetadata::discover(project_path, &system)?;
// Explicitly point ty to the .venv to avoid any set VIRTUAL_ENV variable to take precedence.
project_metadata.apply_override_options(Options {
environment: Some(EnvironmentOptions {
python: Some(RelativePathBuf::cli(".venv")),
..EnvironmentOptions::default()
}),
..Options::default()
});
let db = ProjectDatabase::fallible(project_metadata, system)?;
Ok(Task {
db,
dir: project_path.to_path_buf(),
name: name.to_string(),
cursor,View on GitHub (pinned to 672bb4edf0)
Solutions
- Keep truth fixtures as ordinary named subdirectories under `crates/ty_completion_eval/truth/`
- If hit with an untouched checkout, preserve the command and fixture tree and report it upstream as a harness bug
Defensive patterns
Strategy: validation
Validate before calling
case "$DIR" in /|.|*..) echo "degenerate project path: $DIR" >&2; exit 2;; esac
Prevention
- Keep truth fixtures as ordinary named subdirectories of `truth/`
- Do not script fixture creation at filesystem roots or with `..` components
- Report untouched-tree occurrences upstream as harness bugs
When it happens
Trigger: A truth fixture project path that resolves to a root-like or `..`-terminated path — e.g. a fixture created directly at a filesystem root, or harness path handling producing a degenerate path. Practically unreachable with a normal checkout.
Common situations: Exotic truth-tree layouts produced by scripts or manual experimentation; harness bugs after refactoring the temp-copy logic.
Related errors
- truth source directory `{dir}` does not contain a base name
- The current working directory `{}` contains non-Unicode char
- {truth} does not exist: ty's completion evaluation must be r
- truth source directory `{path}` contains invalid UTF-8
- path `{}` is not valid UTF-8
AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16).
Data as JSON: /api/errors/09eb205e7c3ed90d.
Report an issue: GitHub.