rust-lang/cargo · error

Could not find typos version in workflow

Error message

Could not find typos version in workflow

What it means

xtask-spellcheck parses the GitHub Actions workflow file to find the pinned `crate-ci/typos` version (the `uses: crate-ci/typos@vX.Y.Z` line) and parses it as a semver Version. If no such line is found, it bails with 'Could not find typos version in workflow'.

Source

Thrown at crates/xtask-spellcheck/src/main.rs:130

}

fn extract_workflow_typos_version(metadata: &Metadata) -> anyhow::Result<Version> {
    let ws_root = metadata.workspace_root.as_path().as_std_path();
    let workflow_path = ws_root.join(".github").join("workflows").join("main.yml");
    let file_content = std::fs::read_to_string(workflow_path)?;

    extract_typos_version_from_content(&file_content)
}

fn extract_typos_version_from_content(file_content: &str) -> anyhow::Result<Version> {
    file_content
        .lines()
        .find_map(|line| {
            line.trim()
                .strip_prefix("uses: crate-ci/typos@v")
                .and_then(|v| Version::parse(v).ok())
        })
        .ok_or_else(|| anyhow::anyhow!("Could not find typos version in workflow"))
}

/// If the given executable is installed with the given version, use that,
/// otherwise install via cargo.
pub fn ensure_version_or_cargo_install(
    build_dir: &Path,
    required_version: Version,
) -> io::Result<PathBuf> {
    // Check if the user has a sufficient version already installed
    let bin_path = PathBuf::from(BIN_NAME).with_extension(env::consts::EXE_EXTENSION);
    if let Some(user_version) = get_typos_version(&bin_path) {
        if user_version >= required_version {
            return Ok(bin_path);
        }
    }

    let tool_root_dir = build_dir.join("misc-tools");
    let tool_bin_dir = tool_root_dir.join("bin");

View on GitHub (pinned to eb98b54bc9)

Solutions

  1. Restore a `uses: crate-ci/typos@vX.Y.Z` line in the spellcheck GitHub Actions workflow file.
  2. Update extract_typos_version_from_content's prefix matching if the workflow legitimately changed format.
  3. Pin a concrete version tag (vX.Y.Z) rather than a branch/sha so the semver parse succeeds.

Example fix

// before (workflow)
- uses: crate-ci/typos@master
// after
- uses: crate-ci/typos@v1.20.0
Defensive patterns

Strategy: validation

Validate before calling

// Verify the workflow references typos with a version tag
let wf = std::fs::read_to_string(workflow_path)?;
if !wf.contains("uses: crate-ci/typos@v") {
    eprintln!("workflow missing crate-ci/typos@vX.Y.Z reference");
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Running `cargo spellcheck` when the workflow file no longer contains a `uses: crate-ci/typos@v...` line (renamed action, changed format, missing tag prefix), so Version::parse never succeeds.

Common situations: Editing the CI workflow to use a fork or a different action reference; bumping via dependabot that changes the line format; removing the typos step; the workflow path moved.

Related errors


AI-assisted analysis of rust-lang/cargo@eb98b54bc9 (2026-08-11). Data as JSON: /api/errors/47af10635327aba5. Report an issue: GitHub.