astral-sh/ruff · error
could not find any ` ` directives in any of the files in
Error message
could not find any `<CURSOR>` directives in any of the files in `{src_dir}` What it means
copy_file records every `<CURSOR>` directive it finds in copied fixture files; after copying the project, copy_project asserts with anyhow::ensure! that at least one cursor was found. This error means the fixture project contains no `<CURSOR>` marker in any file, so no completion task can be built from it.
Solutions
- Add a `<CURSOR>` directive at the expected completion position in the fixture file, e.g. `x.<CURSOR>` or `def func(<CURSOR>)`
- Verify with `grep -R '<CURSOR>' crates/ty_completion_eval/truth/<fixture>` that at least one exists
- Ensure copy_file is scanning the files you edited (the file must live inside src_dir, not be excluded from iteration)
Example fix
// before (fixture: completion.rs) let value: i32 = foo.; // after (fixture: completion.rs) let value: i32 = foo.<CURSOR>
Defensive patterns
Strategy: validation
Validate before calling
fn ensure_cursor_present(fixture_dir: &std::path::Path) -> std::io::Result<()> {
let has_cursor = std::fs::read_dir(fixture_dir)?
.filter_map(|e| e.ok())
.filter(|e| e.path().is_file())
.any(|e| std::fs::read_to_string(e.path())
.map(|c| c.contains("<CURSOR>"))
.unwrap_or(false));
if !has_cursor {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"no <CURSOR> directive found in fixture",
));
}
Ok(())
} Try / catch
match copy_project(&src_dir, &dst_dir) {
Ok(cursors) => cursors,
Err(e) if e.to_string().contains("<CURSOR>") => {
eprintln!("add a <CURSOR> directive to at least one file in {}: {e}", src_dir.display());
std::process::exit(2);
}
Err(e) => return Err(e),
} Prevention
- Include a `<CURSOR>` marker in every new truth fixture before running the evaluation
- Grep for `<CURSOR>` after editing fixture files to confirm the marker survived cleanup
- Keep fixture files inside the scanned src_dir so copy_file actually reads them
When it happens
Trigger: Running the completion evaluation on a truth fixture whose files lack any literal `<CURSOR>` token (forgotten marker, marker renamed, or fixture directory copied without its source files containing cursors).
Common situations: Adding a new fixture under crates/ty_completion_eval/truth/ without inserting `<CURSOR>`; a cleanup pass stripped the marker as a placeholder; editing a fixture file and accidentally deleting the marker.
Related errors
- project directory ` ` does not contain a base name
- truth source directory
- Expected to handle named fields
- invalid default warning pattern
- path ` ` is not valid UTF-8
AI-assisted analysis of astral-sh/ruff@5bb508f594 (2026-09-05).
Data as JSON: /api/errors/0f7a8a2c65c73840.
Report an issue: GitHub.
Appendix: source
Thrown at crates/ty_completion_eval/src/main.rs:577
let src = SystemPath::from_std_path(dent.path()).ok_or_else(|| {
anyhow::anyhow!("path `{}` is not valid UTF-8", dent.path().display())
})?;
let name = src
.strip_prefix(src_dir)
.expect("descendent of `src_dir` must start with `src`");
// let name = src
// .file_name()
// .ok_or_else(|| anyhow::anyhow!("path `{src}` is missing a basename"))?;
let dst = dst_dir.join(name);
if dent.file_type().is_dir() {
std::fs::create_dir_all(dst.as_std_path())
.with_context(|| format!("failed to create directory `{dst}`"))?;
} else {
cursors.extend(copy_file(src, &dst)?);
}
}
anyhow::ensure!(
!cursors.is_empty(),
"could not find any `<CURSOR>` directives in any of the files in `{src_dir}`",
);
Ok(cursors)
}
/// Copies `src` to `dst` while looking for cursor directives.
///
/// Each cursor directive looks like:
/// `<CURSOR [expected-module.]expected-symbol>`.
///
/// When occurrences of cursor directives are found, then they are
/// replaced with the empty string. The position of each occurrence is
/// recorded, which points to the correct place in a document where all
/// cursor directives are omitted.
///
/// # Errors
///View on GitHub (pinned to 5bb508f594)