astral-sh/ruff · error · anyhow::Error
The current working directory
Error message
The current working directory `{}` contains non-Unicode characters. ty only supports Unicode paths. What it means
An anyhow error raised at ty server startup: the process's current working directory contains non-Unicode bytes, and ty's path handling only supports Unicode paths, so no workspace can be rooted there. The original std::env::current_dir failure or invalid path is wrapped with context.
Solutions
- Run ty from a directory whose path is valid Unicode
- Pass an explicit workspace folder instead of relying on the current directory
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/ty_server/src/lib.rs:43 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/841d129a16176302.
Report an issue: GitHub.
Appendix: 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 26f38c119c)