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

The completion-evaluation harness applies the same startup gate as the main ty binary: it converts the current working directory to a `SystemPathBuf` and aborts when the path contains bytes that are not valid UTF-8, because ty's path layer is Unicode-only on all platforms.

Source

Thrown at crates/ty_completion_eval/src/main.rs:133

    fn matches_task(&self, task: &Task) -> bool {
        self.task_name == task.name
            && self
                .file_name
                .as_ref()
                .is_none_or(|name| name == task.cursor_name())
            && self.index.is_none_or(|index| index == task.cursor.index)
    }
}

fn main() -> anyhow::Result<ExitCode> {
    let args = Cli::parse();

    // 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()
            )
        })?
    };
    // Where we store our truth data.
    let truth = cwd.join("crates").join("ty_completion_eval").join("truth");
    anyhow::ensure!(
        truth.as_std_path().exists(),
        "{truth} does not exist: ty's completion evaluation must be run from the root \
         of the ruff repository",
        truth = truth.as_std_path().display(),
    );

    // The temporary directory at which we copy our truth
    // data to. We do this because we can't use the truth
    // data as-is with its `<CURSOR>` annotations (and perhaps

View on GitHub (pinned to 672bb4edf0)

Solutions

  1. cd into (or re-checkout the repo under) a fully UTF-8 path and re-run
  2. Rename the offending directory component and retry
  3. Set a UTF-8 locale and recreate any damaged directories

Example fix

# before
cd $'ws\xff/ruff' && cargo run -p ty_completion_eval -- all
# after
mv $'ws\xff' ws-safe && cd ws-safe/ruff && cargo run -p ty_completion_eval -- all
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; eval harness cannot run here" >&2; exit 2; }

Prevention

When it happens

Trigger: Running `cargo run -p ty_completion_eval` (or the built binary) from a directory whose absolute path includes invalid UTF-8 byte sequences; the harness additionally requires the ruff repo root, so non-standard checkout locations compound the problem.

Common situations: Checkouts under legacy-encoded home directories; CI workspaces with byte-mangled components; sandbox/container mounts with non-UTF-8 paths.

Related errors


AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16). Data as JSON: /api/errors/55bc21113a9a12a4. Report an issue: GitHub.