{"record":{"id":"0f7a8a2c65c73840","repo":"astral-sh/ruff","slug":"could-not-find-any-cursor-directives-in-any-of","errorCode":null,"errorMessage":"could not find any `<CURSOR>` directives in any of the files in `{src_dir}`","messagePattern":"could not find any `<CURSOR>` directives in any of the files in `(.+?)`","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_completion_eval/src/main.rs","lineNumber":577,"sourceCode":"\n        let src = SystemPath::from_std_path(dent.path()).ok_or_else(|| {\n            anyhow::anyhow!(\"path `{}` is not valid UTF-8\", dent.path().display())\n        })?;\n        let name = src\n            .strip_prefix(src_dir)\n            .expect(\"descendent of `src_dir` must start with `src`\");\n        // let name = src\n        // .file_name()\n        // .ok_or_else(|| anyhow::anyhow!(\"path `{src}` is missing a basename\"))?;\n        let dst = dst_dir.join(name);\n        if dent.file_type().is_dir() {\n            std::fs::create_dir_all(dst.as_std_path())\n                .with_context(|| format!(\"failed to create directory `{dst}`\"))?;\n        } else {\n            cursors.extend(copy_file(src, &dst)?);\n        }\n    }\n    anyhow::ensure!(\n        !cursors.is_empty(),\n        \"could not find any `<CURSOR>` directives in any of the files in `{src_dir}`\",\n    );\n    Ok(cursors)\n}\n\n/// Copies `src` to `dst` while looking for cursor directives.\n///\n/// Each cursor directive looks like:\n/// `<CURSOR [expected-module.]expected-symbol>`.\n///\n/// When occurrences of cursor directives are found, then they are\n/// replaced with the empty string. The position of each occurrence is\n/// recorded, which points to the correct place in a document where all\n/// cursor directives are omitted.\n///\n/// # Errors\n///","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/astral-sh/ruff/blob/5bb508f59481c1a02d5c7ff8568b9ffd8a763eef/crates/ty_completion_eval/src/main.rs#L559-L595","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)"],"exampleFix":"// before (fixture: completion.rs)\nlet value: i32 = foo.;\n// after (fixture: completion.rs)\nlet value: i32 = foo.<CURSOR>","handlingStrategy":"validation","validationCode":"fn ensure_cursor_present(fixture_dir: &std::path::Path) -> std::io::Result<()> {\n    let has_cursor = std::fs::read_dir(fixture_dir)?\n        .filter_map(|e| e.ok())\n        .filter(|e| e.path().is_file())\n        .any(|e| std::fs::read_to_string(e.path())\n            .map(|c| c.contains(\"<CURSOR>\"))\n            .unwrap_or(false));\n    if !has_cursor {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            \"no <CURSOR> directive found in fixture\",\n        ));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match copy_project(&src_dir, &dst_dir) {\n    Ok(cursors) => cursors,\n    Err(e) if e.to_string().contains(\"<CURSOR>\") => {\n        eprintln!(\"add a <CURSOR> directive to at least one file in {}: {e}\", src_dir.display());\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["rust","fixtures","completion-eval","configuration"],"backgroundTag":"missing-cursor-directive","analyzedSha":"5bb508f59481c1a02d5c7ff8568b9ffd8a763eef","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}