{"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":null,"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/5bb508f59481c1a02d5c7ff8568b9ffd8a763eef/crates/ty_completion_bench/src/main.rs#L136-L164","documentation":"ty_completion_bench discovers the project root by walking a file's canonicalized ancestors looking for `pyproject.toml`, then converts the found directory to a `SystemPathBuf`. If that ancestor path is not valid UTF-8, it throws this error since ty tooling only supports Unicode paths.","triggerScenarios":"Running the completion benchmark on a file whose project root (the ancestor containing `pyproject.toml`) has a non-UTF-8 path, e.g. under byte-level filenames on Linux.","commonSituations":"Projects checked out under directories named with legacy encodings; benchmark harnesses given files in non-Unicode temp or mount paths.","solutions":["Move or rename the project (and its `pyproject.toml` ancestors) so the full path is valid UTF-8","Copy the project into a UTF-8-safe directory (e.g. /tmp/proj) and rerun the benchmark against that copy"],"exampleFix":"// before\nbench --file /data/caf$(printf '\\xe9')/proj/src/mod.py\n// after\nmv /data/caf$(printf '\\xe9')/proj /tmp/proj\nbench --file /tmp/proj/src/mod.py","handlingStrategy":"validation","validationCode":"import os, sys\nfile = sys.argv[1]\ncanonical = os.path.realpath(file)\nd = canonical\nwhile d != os.path.dirname(d):\n    if os.path.exists(os.path.join(d, 'pyproject.toml')):\n        try:\n            d.encode('utf-8')\n        except UnicodeEncodeError:\n            sys.exit(f\"Project dir {d!r} is not valid UTF-8\")\n        break\n    d = os.path.dirname(d)","typeGuard":null,"tryCatchPattern":"match discover_project_directory(&file) {\n    Err(e) if e.to_string().contains(\"non-Unicode\") => eprintln!(\"Move the project to a UTF-8-safe path and retry\"),\n    result => result,\n}","preventionTips":["Check out benchmark projects under ASCII-only paths","Avoid non-UTF-8 mounts and TMPDIR locations for benchmark inputs","Canonicalize and validate paths in harness scripts before invoking the bench binary"],"tags":["unicode","path-resolution","benchmark"],"backgroundTag":"non-unicode-path","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"}