{"record":{"id":"e52736cffb825859","repo":"astral-sh/ruff","slug":"detected-project-directory-path-contains-non-u","errorCode":null,"errorMessage":"Detected project directory `{path}` contains non-Unicode characters. ty only supports Unicode paths.","messagePattern":"Detected project directory `(.+?)` contains non-Unicode characters\\. ty only supports Unicode paths\\.","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ty_completion_bench/src/main.rs","lineNumber":154,"sourceCode":"    offset: ruff_text_size::TextSize,\n) -> anyhow::Result<Vec<Completion<'db>>> {\n    let file = system_path_to_file(db, path)\n        .with_context(|| format!(\"failed to get database file for `{path}`\"))?;\n    let settings = ty_ide::CompletionSettings::default();\n    Ok(ty_ide::completion(\n        db,\n        &settings,\n        CompletionCapabilities::default(),\n        db.program_file(file),\n        offset,\n    ))\n}\n\nfn discover_project_directory(file: &SystemPath) -> anyhow::Result<SystemPathBuf> {\n    for ancestor in file.as_std_path().canonicalize()?.ancestors() {\n        if ancestor.join(\"pyproject.toml\").exists() {\n            return SystemPathBuf::from_path_buf(ancestor.to_path_buf()).map_err(|path| {\n                anyhow!(\n                    \"Detected project directory `{path}` contains non-Unicode characters. \\\n                     ty only supports Unicode paths.\",\n                    path = path.display()\n                )\n            });\n        }\n    }\n    anyhow::bail!(\"could not find `pyproject.toml` in any ancestor of `{file}`\")\n}\n","sourceCodeStart":136,"sourceCodeEnd":164,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty_completion_bench/src/main.rs#L136-L164","documentation":"ty_completion_bench locates the benchmark file's project by canonicalizing the path and walking ancestors for a `pyproject.toml`; when the found directory cannot convert to a `SystemPathBuf` because it contains non-UTF-8 bytes, ty's Unicode-only path layer rejects it with the offending path echoed.","triggerScenarios":"Benchmarking a file whose project directory — after `canonicalize()` resolves symlinks — contains byte sequences that are not valid UTF-8 (legacy-locale directory names, mangled archive extractions).","commonSituations":"Unix machines running without a UTF-8 locale; projects restored from backups/archives with encoding damage; sibling directories with byte-only names on the path from root to the project.","solutions":["Move or rename the offending directory component so the whole path is valid UTF-8","Re-clone the benchmark project into a clean Unicode path and benchmark files there","Set a UTF-8 locale (LANG/LC_ALL) before creating directories so names come out UTF-8"],"exampleFix":"# before\ncd $'proj\\xff/bench' && cargo run -p ty_completion_bench -- snippet.py\n# after\nmv $'proj\\xff' proj-safe && cd proj-safe/bench && cargo run -p ty_completion_bench -- snippet.py","handlingStrategy":"validation","validationCode":"python3 -c 'import os,sys; os.path.dirname(os.path.realpath(sys.argv[1])).encode(\"utf-8\")' \"$FILE\" \\\n  || { echo \"project path is not valid UTF-8\" >&2; exit 2; }","typeGuard":"// Rust (for harness embedders)\nfn project_dir_is_unicode(file: &std::path::Path) -> bool {\n    file.canonicalize().map(|p| p.to_str().is_some()).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Keep benchmark projects under fully Unicode paths","Avoid restoring projects from archives with unknown filename encodings","Set a UTF-8 locale when creating project directories"],"tags":["unicode","paths","benchmark","environment"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}