{"record":{"id":"09eb205e7c3ed90d","repo":"astral-sh/ruff","slug":"project-directory-project-path-does-not-contai","errorCode":null,"errorMessage":"project directory `{project_path}` does not contain a base name","messagePattern":"project directory `(.+?)` does not contain a base name","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_completion_eval/src/main.rs","lineNumber":277,"sourceCode":"    db: ProjectDatabase,\n    dir: SystemPathBuf,\n    name: String,\n    cursor: Cursor,\n    settings: ty_ide::CompletionSettings,\n}\n\nimpl Task {\n    /// Create a new task for the Python project at `project_path`.\n    ///\n    /// `truth` should correspond to the completion configuration and the\n    /// expected answer for completions at the given `cursor` position.\n    fn new(\n        project_path: &SystemPath,\n        truth: &CompletionTruth,\n        cursor: Cursor,\n    ) -> anyhow::Result<Task> {\n        let name = project_path.file_name().ok_or_else(|| {\n            anyhow::anyhow!(\"project directory `{project_path}` does not contain a base name\")\n        })?;\n\n        let system = OsSystem::new(project_path);\n        let mut project_metadata = ProjectMetadata::discover(project_path, &system)?;\n        // Explicitly point ty to the .venv to avoid any set VIRTUAL_ENV variable to take precedence.\n        project_metadata.set_override_options(Options {\n            environment: Some(EnvironmentOptions {\n                python: Some(RelativePathBuf::cli(\".venv\")),\n                ..EnvironmentOptions::default()\n            }),\n            ..Options::default()\n        });\n        let db = ProjectDatabase::fallible(project_metadata, system)?;\n        Ok(Task {\n            db,\n            dir: project_path.to_path_buf(),\n            name: name.to_string(),\n            cursor,","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/astral-sh/ruff/blob/5bb508f59481c1a02d5c7ff8568b9ffd8a763eef/crates/ty_completion_eval/src/main.rs#L259-L295","documentation":"Task::new in ty_completion_eval requires the project directory path to end with a real directory name. It calls SystemPath::file_name() and fails when the path is empty or terminates in `..` or `/` with no final component, because the directory name is used as the human-readable task name.","triggerScenarios":"Calling Task::new with a SystemPath built from \"/\", \".\", \"foo/..\", or a path that normalizes to the filesystem root; also paths constructed by joining that end with a trailing separator resolving to root.","commonSituations":"A completion-evaluation task CSV or fixture path is misconfigured to point at the repository root or a parent directory; a path was built with an erroneous trailing `..`; an empty path from environment/config substitution.","solutions":["Point the task's project_path at the actual fixture directory (e.g. crates/ty_completion_eval/truth/<fixture>), not the root or a parent","Remove any trailing `..` or `/` segments from the configured path","Use SystemPath::from_path with an absolute, non-root directory path and verify file_name() succeeds before calling Task::new"],"exampleFix":"// before\nlet task = Task::new(&SystemPath::from(\"..\").unwrap(), &truth, cursor)?;\n// after\nlet project = std::path::PathBuf::from(\"crates/ty_completion_eval/truth/my-project\").canonicalize()?;\nlet task = Task::new(&SystemPath::from_std_path(&project).unwrap(), &truth, cursor)?;","handlingStrategy":"validation","validationCode":"fn validate_project_path(p: &SystemPath) -> Result<(), String> {\n    match p.file_name() {\n        Some(_) if p.as_std_path().is_dir() => Ok(()),\n        Some(_) => Err(format!(\"`{}` is not a directory\", p.display())),\n        None => Err(format!(\"`{}` has no base name (empty, root, or `..`)\", p.display())),\n    }\n}","typeGuard":"fn has_base_name(p: &SystemPath) -> bool {\n    p.file_name().is_some()\n}","tryCatchPattern":"match Task::new(&project_path, &truth, cursor) {\n    Ok(task) => run(task),\n    Err(e) if e.to_string().contains(\"does not contain a base name\") => {\n        eprintln!(\"project_path must be a concrete fixture directory: {e}\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always pass an absolute, canonicalized directory with a real final component","Never build paths by joining with `..`; canonicalize instead","Check SystemPath::file_name() in setup code before launching an evaluation run"],"tags":["rust","path","configuration","completion-eval"],"backgroundTag":"invalid-path-base-name","analyzedSha":"5bb508f59481c1a02d5c7ff8568b9ffd8a763eef","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}