astral-sh/ruff · error
The current working directory `{}` contains non-Unicode char
Error message
The current working directory `{}` contains non-Unicode characters. ty only supports Unicode paths. What it means
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.
Source
Thrown at crates/ty_server/src/lib.rs:43
/// A common result type used in most cases where a
/// result type is needed.
pub(crate) type Result<T> = anyhow::Result<T>;
pub fn run_server() -> anyhow::Result<()> {
let _ = print_interactive_warning();
let four = NonZeroUsize::new(4).unwrap();
// by default, we set the number of worker threads to `num_cpus`, with a maximum of 4.
let worker_threads = std::thread::available_parallelism()
.unwrap_or(four)
.min(four);
let (connection, io_threads) = Connection::stdio();
let cwd = {
let cwd = std::env::current_dir().context("Failed to get the current working directory")?;
SystemPathBuf::from_path_buf(cwd).map_err(|path| {
anyhow::anyhow!(
"The current working directory `{}` contains non-Unicode characters. \
ty only supports Unicode paths.",
path.display()
)
})?
};
// This is to complement the `LSPSystem` if the document is not available in the index.
let fallback_system = Arc::new(OsSystem::new(cwd));
let server_result = Server::new(worker_threads, connection, fallback_system, false)
.context("Failed to start server")?
.run();
let io_result = io_threads.join();
let result = match (server_result, io_result) {
(Ok(()), Ok(())) => Ok(()),View on GitHub (pinned to 672bb4edf0)
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
Defensive patterns
Strategy: validation
Validate before calling
// TS: spawn the server with an explicit, UTF-8-safe cwd
const cwd = isUtf8(process.cwd()) ? process.cwd() : os.homedir();
spawnServer({ cwd, stdio: ['pipe', 'pipe', 'pipe'] });
function isUtf8(p: string): boolean {
return !p.includes('\uFFFD'); // replacement char indicates decoding loss
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to get the current working directory while creating a
- Workspace path is not valid UTF-8: {}
- Workspace URI is not valid UTF8
- The current working directory `{}` contains non-Unicode char
- Detected project directory `{path}` contains non-Unicode cha
AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16).
Data as JSON: /api/errors/841d129a16176302.
Report an issue: GitHub.