astral-sh/ruff · error · anyhow::Error

{truth} does not exist: ty's completion evaluation must be r

Error message

{truth} does not exist: ty's completion evaluation must be run from the root of the ruff repository

What it means

ty_completion_eval hard-codes its layout relative to the working directory: it joins `crates/ty_completion_eval/truth` onto the cwd and asserts the directory exists. The harness is tied to the ruff repository structure, so invoking it from any other directory fails this check before any work starts.

Source

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

}

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
    // any other future annotations we add).
    let mut tmp_eval_dir = tempfile::Builder::new()
        .prefix("ty-completion-eval-")
        .tempdir()
        .context("Failed to create temporary directory")?;
    let tmp_eval_path = SystemPath::from_std_path(tmp_eval_dir.path())
        .ok_or_else(|| {
            anyhow::anyhow!(
                "Temporary directory path is not valid UTF-8: {}",

View on GitHub (pinned to 672bb4edf0)

Solutions

  1. cd to the ruff repository root and re-run the exact command from the docs
  2. Verify the fixtures exist: `test -d crates/ty_completion_eval/truth`
  3. If using sparse checkout, reconfigure it to include `crates/ty_completion_eval`

Example fix

# before (run from a subdirectory)
crates/ $ cargo run -p ty_completion_eval -- all
# after (run from repo root)
$ cargo run -p ty_completion_eval -- all --threshold 0.4 --tasks crates/ty_completion_eval/completion-evaluation-tasks.csv
Defensive patterns

Strategy: validation

Validate before calling

cd "$(git rev-parse --show-toplevel 2>/dev/null)" \
  && test -d crates/ty_completion_eval/truth \
  || { echo "run ty_completion_eval from the ruff repo root" >&2; exit 2; }

Prevention

When it happens

Trigger: Running `cargo run -p ty_completion_eval` from a subdirectory of the repo or from outside the checkout (cargo passes the invoking shell's cwd to the child process); a sparse/partial checkout that excluded the truth fixtures.

Common situations: Running the compiled binary directly from `$HOME` or `/tmp`; CI scripts that cd elsewhere before invoking; fresh clones with sparse-checkout rules missing `crates/ty_completion_eval/truth`.

Related errors


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