{"record":{"id":"c0bea970034917ca","repo":"astral-sh/ruff","slug":"the-current-working-directory-contains-non-un","errorCode":null,"errorMessage":"The current working directory `{}` contains non-Unicode characters. ty only supports Unicode paths.","messagePattern":"The current working directory `(.+?)` contains non-Unicode characters\\. ty only supports Unicode paths\\.","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ty/src/lib.rs","lineNumber":108,"sourceCode":"fn run_check(args: CheckCommand) -> anyhow::Result<ExitStatus> {\n    // Enabled ANSI colors on Windows 10.\n    #[cfg(windows)]\n    assert!(colored::control::set_virtual_terminal(true).is_ok());\n\n    set_colored_override(args.color);\n\n    let verbosity = args.verbosity.level();\n    let _guard = setup_tracing(verbosity, args.color.unwrap_or_default())?;\n\n    let printer = Printer::new(verbosity, args.no_progress);\n\n    tracing::debug!(\"Version: {}\", version::version());\n\n    // The base path to which all CLI arguments are relative to.\n    let cwd = {\n        let cwd = std::env::current_dir().context(\"Failed to get the current working directory\")?;\n        SystemPathBuf::from_path_buf(cwd).map_err(|path| {\n            anyhow!(\n                \"The current working directory `{}` contains non-Unicode characters. \\\n                ty only supports Unicode paths.\",\n                path.display()\n            )\n        })?\n    };\n\n    let project_path = args\n        .project\n        .as_ref()\n        .map(|project| {\n            if project.as_std_path().is_dir() {\n                Ok(SystemPath::absolute(project, &cwd))\n            } else {\n                Err(anyhow!(\n                    \"Provided project path `{project}` is not a directory\"\n                ))\n            }","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty/src/lib.rs#L90-L126","documentation":"At startup the `ty` binary converts the process working directory into a `SystemPathBuf`; on platforms where paths are byte strings (Linux/macOS) a cwd containing invalid UTF-8 bytes makes `SystemPathBuf::from_path_buf` return the original path as an error. ty standardizes on Unicode paths on every platform, so it aborts with this message — echoing the offending path via `path.display()` — instead of guessing how to handle the bytes.","triggerScenarios":"Running any `ty` subcommand (`ty check`, `ty server`, `ty rule`, ...) from a directory whose absolute path includes a byte sequence that is not valid UTF-8, e.g. a directory created under a legacy single-byte locale or restored from an archive that mangled filenames.","commonSituations":"Unix checkouts in directories named with Latin-1/CP1252 bytes; CI agents whose workspace root contains non-UTF-8 components; paths created by tools running without a UTF-8 locale; deliberate byte-name fuzz testing.","solutions":["Move or rename the non-UTF-8 directory component so the full cwd is valid UTF-8, then re-run ty","Re-clone or re-checkout the project into a clean Unicode path and work from there","Set a UTF-8 locale (e.g. LANG=en_US.UTF-8) and recreate the directory so future names are UTF-8"],"exampleFix":"# before (cwd contains invalid UTF-8 bytes)\ncd $'bad\\xff/path/project' && ty check\n# after\nmv $'bad\\xff' bad-safe && cd bad-safe/path/project && ty check","handlingStrategy":"validation","validationCode":"python3 -c 'import os; os.getcwd().encode(\"utf-8\")' 2>/dev/null \\\n  || { echo \"cwd is not valid UTF-8; ty cannot run here\" >&2; exit 2; }","typeGuard":"// Rust (for embedders of ty's path layer)\nfn is_unicode_path(p: &std::path::Path) -> bool {\n    p.to_str().is_some()\n}","tryCatchPattern":null,"preventionTips":["Keep checkouts and working directories strictly UTF-8","Set a UTF-8 locale (LANG/LC_ALL) on Unix so tools create UTF-8 names","In CI, sanity-check the workspace path encoding before invoking ty"],"tags":["ty","cli","unicode","paths","environment"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}