{"record":{"id":"841d129a16176302","repo":"astral-sh/ruff","slug":"the-current-working-directory-contains-non-un-841d12","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":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_server/src/lib.rs","lineNumber":43,"sourceCode":"/// A common result type used in most cases where a\n/// result type is needed.\npub(crate) type Result<T> = anyhow::Result<T>;\n\npub fn run_server() -> anyhow::Result<()> {\n    let _ = print_interactive_warning();\n    let four = NonZeroUsize::new(4).unwrap();\n\n    // by default, we set the number of worker threads to `num_cpus`, with a maximum of 4.\n    let worker_threads = std::thread::available_parallelism()\n        .unwrap_or(four)\n        .min(four);\n\n    let (connection, io_threads) = Connection::stdio();\n\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::anyhow!(\n                \"The current working directory `{}` contains non-Unicode characters. \\\n                    ty only supports Unicode paths.\",\n                path.display()\n            )\n        })?\n    };\n\n    // This is to complement the `LSPSystem` if the document is not available in the index.\n    let fallback_system = Arc::new(OsSystem::new(cwd));\n\n    let server_result = Server::new(worker_threads, connection, fallback_system, false)\n        .context(\"Failed to start server\")?\n        .run();\n\n    let io_result = io_threads.join();\n\n    let result = match (server_result, io_result) {\n        (Ok(()), Ok(())) => Ok(()),","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty_server/src/lib.rs#L25-L61","documentation":"At LSP server startup, ty converts the process current working directory to a SystemPathBuf and requires it to be Unicode (valid UTF-8). If the OS path bytes are not valid UTF-8, startup aborts: ty only supports Unicode paths.","triggerScenarios":"Launching the ty server with a cwd whose raw bytes are invalid UTF-8 — e.g. a Latin-1/Shift-JIS encoded directory name on Linux, or a path component mangled by a non-UTF-8 locale.","commonSituations":"Editor launched from a legacy-encoded directory, CI containers with a non-UTF-8 locale (LC_CTYPE), NFS/smb mounts with odd filenames, or an LSP client spawning the server with an inherited bad cwd.","solutions":["Run/launch the server from a directory whose full path is valid UTF-8 (rename the offending directory)","Set the client's server-cwd configuration to a known-good UTF-8 directory (e.g. the workspace root)","Fix the environment locale (export LC_CTYPE=C.UTF-8) so paths round-trip as UTF-8"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// TS: spawn the server with an explicit, UTF-8-safe cwd\nconst cwd = isUtf8(process.cwd()) ? process.cwd() : os.homedir();\nspawnServer({ cwd, stdio: ['pipe', 'pipe', 'pipe'] });\n\nfunction isUtf8(p: string): boolean {\n  return !p.includes('\\uFFFD'); // replacement char indicates decoding loss\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Spawn language servers with cwd set to the workspace root, not inherited from a wrapper","Run editors and CI under a UTF-8 locale (LC_CTYPE=C.UTF-8)","Rename legacy-encoded directories before opening them as workspaces"],"tags":["server","startup","filesystem","unicode","encoding","cwd"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}