astral-sh/ruff · error

could not find task named

Error message

could not find task named `{}`

What it means

The `show-one` command of `ty_completion_eval` searches the loaded task sources under `crates/ty_completion_eval/truth/` for one whose fixture name matches `--task-name` (and optional file/index filters). If no source fixture matches, the tool bails with this message. It indicates the requested fixture does not exist by that name.

Solutions

  1. List the available fixtures under `crates/ty_completion_eval/truth/` and use the exact name
  2. Run the tool from the root of the ruff repository so the `truth` directory is found
  3. Check for typos or recent renames of the fixture; pass `--file-name`/`--index` filters only if the fixture supports them
  4. Run `cargo run --package ty_completion_eval -- all` to see which tasks exist

Example fix

// before
cargo run --package ty_completion_eval -- show-one completoin.rs
// after
cargo run --package ty_completion_eval -- show-one completion.rs
Defensive patterns

Strategy: validation

Validate before calling

ls crates/ty_completion_eval/truth/ | grep -x '<task-name>' || echo "fixture not found"

Try / catch

match eval.run() {
    Err(e) if e.to_string().contains("could not find task named") => {
        eprintln!("unknown fixture; check crates/ty_completion_eval/truth/ names");
        std::process::ExitCode::from(1)
    }
    other => other,
}

Prevention

When it happens

Trigger: Running `ty_completion_eval show-one <name>` where `<name>` does not match any fixture directory/file in the truth data, the name is misspelled, or the tool is run from the wrong repository root so the truth data set is incomplete.

Common situations: Typo in the fixture name or using a fixture that was renamed/deleted; forgetting to run from the ruff repository root; adding a new truth fixture but invoking it before it is registered; confusing fixture-name with cursor-name or file-name filters.

Related errors


AI-assisted analysis of astral-sh/ruff@5bb508f594 (2026-09-05). Data as JSON: /api/errors/424f86bd33c8e8b7. Report an issue: GitHub.

Appendix: source

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

    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: {}",
                tmp_eval_dir.path().display()
            )
        })?
        .to_path_buf();

    let sources = TaskSource::all(&truth)?;
    match args.command {
        Command::ShowOne(ref cmd) => {
            tmp_eval_dir.disable_cleanup(cmd.keep_tmp_dir);

            let Some(source) = sources
                .iter()
                .find(|source| cmd.matches_source_task(source))
            else {
                anyhow::bail!("could not find task named `{}`", cmd.task_name);
            };
            let tasks = source.to_tasks(&tmp_eval_path)?;
            let matching: Vec<&Task> = tasks.iter().filter(|task| cmd.matches_task(task)).collect();
            anyhow::ensure!(
                !matching.is_empty(),
                "could not find any tasks matching the given criteria",
            );
            anyhow::ensure!(
                matching.len() < 2,
                "found more than one task matching the given criteria",
            );
            let task = &matching[0];
            let completions = task.completions()?;

            let mut stdout = std::io::stdout().lock();
            for (i, c) in completions.iter().enumerate() {
                write!(stdout, "{}", c.name.as_str())?;
                if let Some(module_name) = c.module_name {

View on GitHub (pinned to 5bb508f594)