Skip to content

Unexpected failure in cargo add when mistyping "-" as "_" for packages with yanked versions #14893

Closed
@Property404

Description

@Property404

Problem

Cargo has a feature that corrects mistyped hyphens and underscores, which are easy to get confused.

Both cargo add utf8-parser and cargo add utf8_parser will work as expected and pull the latest version of utf8-parser - that's great

However, I am experiencing some inconsistent behavior with owo-colors, whose latest release is a yanked 5.0.0

Running cargo add owo-colors produces:

avsdf $ cargo add owo-colors
    Updating crates.io index
      Adding owo-colors v4.1.0 to dependencies
             Features:
             - alloc
             - supports-color
             - supports-colors
    Updating crates.io index
     Locking 1 package to latest compatible version
      Adding owo-colors v4.1.0

This adds the latest non-yanked version of owo-colors, which is v4.1.0. Great!

However, when I run cargo add owo_colors:

avsdf $ cargo add owo_colors
    Updating crates.io index
warning: translating `owo_colors` to `owo-colors`
error: the crate `[email protected]` could not be found in registry index.

So it seems with the mistype, it tries to add the latest version, but the latest version is yanked.

For posterity, here is a screen shot of the current state of owo-colors versions:
Image

Expected Behavior: cargo add owo_colors and cargo add owo-colors have the same behavior
Actual Behavior:cargo add owo_colors fails while cargo add owo-colors does not

Steps

  1. rustup update && rustup default nightly
  2. cargo new avsdf
  3. cd avsdf
  4. cargo add owo_colors

The last command will fail with error: the crate '[email protected]' could not be found in registry index

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.85.0-nightly (05f54fdc3 2024-12-03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugCommand-addS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions