astral-sh/ruff · error · anyhow::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 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.
Source
Thrown at crates/ty/src/lib.rs:108
fn run_check(args: CheckCommand) -> anyhow::Result<ExitStatus> {
// Enabled ANSI colors on Windows 10.
#[cfg(windows)]
assert!(colored::control::set_virtual_terminal(true).is_ok());
set_colored_override(args.color);
let verbosity = args.verbosity.level();
let _guard = setup_tracing(verbosity, args.color.unwrap_or_default())?;
let printer = Printer::new(verbosity, args.no_progress);
tracing::debug!("Version: {}", version::version());
// The base path to which all CLI arguments are relative to.
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!(
"The current working directory `{}` contains non-Unicode characters. \
ty only supports Unicode paths.",
path.display()
)
})?
};
let project_path = args
.project
.as_ref()
.map(|project| {
if project.as_std_path().is_dir() {
Ok(SystemPath::absolute(project, &cwd))
} else {
Err(anyhow!(
"Provided project path `{project}` is not a directory"
))
}View on GitHub (pinned to 672bb4edf0)
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
Example fix
# before (cwd contains invalid UTF-8 bytes) cd $'bad\xff/path/project' && ty check # after mv $'bad\xff' bad-safe && cd bad-safe/path/project && ty check
Defensive patterns
Strategy: validation
Validate before calling
python3 -c 'import os; os.getcwd().encode("utf-8")' 2>/dev/null \
|| { echo "cwd is not valid UTF-8; ty cannot run here" >&2; exit 2; } Type guard
// Rust (for embedders of ty's path layer)
fn is_unicode_path(p: &std::path::Path) -> bool {
p.to_str().is_some()
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Provided project path `{project}` is not a directory
- Detected project directory `{path}` contains non-Unicode cha
- The current working directory `{}` contains non-Unicode char
- `--watch` is not supported with uv workspace integration
- {e}
AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16).
Data as JSON: /api/errors/c0bea970034917ca.
Report an issue: GitHub.