Repository: rust-lang/cargo (rust)

Issue:
Unexpected failure in `cargo add` when mistyping "-" as "_" for packages with yanked versions
### 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 `owo-colors@5.0.0` 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](https://github.com/user-attachments/assets/53357b51-66dd-45ff-8310-cbeaf807b1c6)

**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

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

The last command will fail with `error: the crate 'owo-colors@5.0.0' could not be found in registry index`

### Possible Solution(s)

_No response_

### Notes

_No response_

### Version

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

Pull request:
fix(add): Don't select yanked versions when normalizing names
### What does this PR try to resolve?

Fixes #14893

In writing a test for this, I had a hard time finding the other tests as they mixed 
- Having an `add_` prefix
- Calling this fuzzy vs normalized

So I made the test names consistent

### How should we test and review this PR?



### Additional information


Patch:
diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs
index 4a4c22b46..ed36c31f3 100644
--- a/src/cargo/sources/registry/mod.rs
+++ b/src/cargo/sources/registry/mod.rs
@@ -856,7 +856,13 @@ impl<'gctx> Source for RegistrySource<'gctx> {
                     }
                     any_pending |= self
                         .index
-                        .query_inner(name_permutation, &req, &mut *self.ops, f)?
+                        .query_inner(name_permutation, &req, &mut *self.ops, &mut |s| {
+                            if !s.is_yanked() {
+                                f(s);
+                            } else if kind == QueryKind::Alternatives {
+                                f(s);
+                            }
+                        })?
                         .is_pending();
                 }
             }


Test patch:
diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs
index ec00ba48c..35ab71346 100644
--- a/tests/testsuite/cargo_add/mod.rs
+++ b/tests/testsuite/cargo_add/mod.rs
@@ -2,9 +2,7 @@ mod add_basic;
 mod add_multiple;
 mod add_no_vendored_package_with_alter_registry;
 mod add_no_vendored_package_with_vendor;
-mod add_normalized_name_external;
 mod add_toolchain;
-mod add_workspace_non_fuzzy;
 mod build;
 mod build_prefer_existing_version;
 mod change_rename_target;
@@ -14,7 +12,6 @@ mod deprecated_default_features;
 mod deprecated_section;
 mod detect_workspace_inherit;
 mod detect_workspace_inherit_features;
-mod detect_workspace_inherit_fuzzy;
 mod detect_workspace_inherit_optional;
 mod detect_workspace_inherit_path_base;
 mod detect_workspace_inherit_public;
@@ -28,7 +25,6 @@ mod features;
 mod features_activated_over_limit;
 mod features_deactivated_over_limit;
 mod features_empty;
-mod features_fuzzy;
 mod features_multiple_occurrences;
 mod features_preserve;
 mod features_spaced_values;
@@ -42,7 +38,6 @@ mod git_inferred_name;
 mod git_inferred_name_multiple;
 mod git_multiple_names;
 mod git_multiple_packages_features;
-mod git_normalized_name;
 mod git_registry;
 mod git_rev;
 mod git_tag;
@@ -75,6 +70,13 @@ mod no_args;
 mod no_default_features;
 mod no_optional;
 mod no_public;
+mod normalize_name_git;
+mod normalize_name_path;
+mod normalize_name_path_existing;
+mod normalize_name_registry;
+mod normalize_name_registry_existing;
+mod normalize_name_registry_yanked;
+mod normalize_name_workspace_dep;
 mod offline_empty_cache;
 mod optional;
 mod overwrite_default_features;
@@ -118,7 +120,6 @@ mod path_base_unstable;
 mod path_dev;
 mod path_inferred_name;
 mod path_inferred_name_conflicts_full_feature;
-mod path_normalized_name;
 mod preserve_dep_std_table;
 mod preserve_features_sorted;
 mod preserve_features_table;
@@ -149,3 +150,4 @@ mod vers;
 mod workspace_name;
 mod workspace_path;
 mod workspace_path_dev;
+mod yanked;
diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/in b/tests/testsuite/cargo_add/normalize_name_git/in
similarity index 100%
rename from tests/testsuite/cargo_add/add_normalized_name_external/in
rename to tests/testsuite/cargo_add/normalize_name_git/in
diff --git a/tests/testsuite/cargo_add/git_normalized_name/mod.rs b/tests/testsuite/cargo_add/normalize_name_git/mod.rs
similarity index 100%
rename from tests/testsuite/cargo_add/git_normalized_name/mod.rs
rename to tests/testsuite/cargo_add/normalize_name_git/mod.rs
diff --git a/tests/testsuite/cargo_add/git_normalized_name/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_git/out/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/git_normalized_name/out/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_git/out/Cargo.toml
diff --git a/tests/testsuite/cargo_add/git_normalized_name/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_git/stderr.term.svg
similarity index 100%
rename from tests/testsuite/cargo_add/git_normalized_name/stderr.term.svg
rename to tests/testsuite/cargo_add/normalize_name_git/stderr.term.svg
diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/dependency/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/in/dependency/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/in/dependency/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path/in/dependency/Cargo.toml
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path/in/dependency/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_path/in/dependency/src/lib.rs
diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/in/primary/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/in/primary/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path/in/primary/Cargo.toml
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path/in/primary/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_path/in/primary/src/lib.rs
diff --git a/tests/testsuite/cargo_add/path_normalized_name/mod.rs b/tests/testsuite/cargo_add/normalize_name_path/mod.rs
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/mod.rs
rename to tests/testsuite/cargo_add/normalize_name_path/mod.rs
diff --git a/tests/testsuite/cargo_add/path_normalized_name/out/dependency/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/out/dependency/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/out/dependency/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path/out/dependency/Cargo.toml
diff --git a/tests/testsuite/cargo_add/path_normalized_name/out/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/out/primary/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/out/primary/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path/out/primary/Cargo.toml
diff --git a/tests/testsuite/cargo_add/path_normalized_name/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_path/stderr.term.svg
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/stderr.term.svg
rename to tests/testsuite/cargo_add/normalize_name_path/stderr.term.svg
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock b/tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.lock
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock
rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.lock
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.toml
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/Cargo.toml
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/src/lib.rs
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/Cargo.toml
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/src/lib.rs
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/mod.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/mod.rs
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/mod.rs
rename to tests/testsuite/cargo_add/normalize_name_path_existing/mod.rs
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/out/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path_existing/out/Cargo.toml
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/Cargo.toml
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/src/lib.rs
diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_path_existing/stderr.term.svg
similarity index 100%
rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/stderr.term.svg
rename to tests/testsuite/cargo_add/normalize_name_path_existing/stderr.term.svg
diff --git a/tests/testsuite/cargo_add/git_normalized_name/in b/tests/testsuite/cargo_add/normalize_name_registry/in
similarity index 100%
rename from tests/testsuite/cargo_add/git_normalized_name/in
rename to tests/testsuite/cargo_add/normalize_name_registry/in
diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs b/tests/testsuite/cargo_add/normalize_name_registry/mod.rs
similarity index 100%
rename from tests/testsuite/cargo_add/add_normalized_name_external/mod.rs
rename to tests/testsuite/cargo_add/normalize_name_registry/mod.rs
diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry/out/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/add_normalized_name_external/out/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_registry/out/Cargo.toml
diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_registry/stderr.term.svg
similarity index 100%
rename from tests/testsuite/cargo_add/add_normalized_name_external/stderr.term.svg
rename to tests/testsuite/cargo_add/normalize_name_registry/stderr.term.svg
diff --git a/tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry_existing/in/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_registry_existing/in/Cargo.toml
diff --git a/tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_registry_existing/in/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_registry_existing/in/src/lib.rs
diff --git a/tests/testsuite/cargo_add/features_fuzzy/mod.rs b/tests/testsuite/cargo_add/normalize_name_registry_existing/mod.rs
similarity index 100%
rename from tests/testsuite/cargo_add/features_fuzzy/mod.rs
rename to tests/testsuite/cargo_add/normalize_name_registry_existing/mod.rs
diff --git a/tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry_existing/out/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_registry_existing/out/Cargo.toml
diff --git a/tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_registry_existing/stderr.term.svg
similarity index 100%
rename from tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg
rename to tests/testsuite/cargo_add/normalize_name_registry_existing/stderr.term.svg
diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/in b/tests/testsuite/cargo_add/normalize_name_registry_yanked/in
new file mode 120000
index 000000000..6c6a27fcf
--- /dev/null
+++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/in
@@ -0,0 +1,1 @@
+../add-basic.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs b/tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs
new file mode 100644
index 000000000..4b3bedb34
--- /dev/null
+++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs
@@ -0,0 +1,31 @@
+use cargo_test_support::compare::assert_ui;
+use cargo_test_support::current_dir;
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+use cargo_test_support::str;
+use cargo_test_support::Project;
+
+#[cargo_test]
+fn case() {
+    cargo_test_support::registry::init();
+    cargo_test_support::registry::Package::new("linked-hash-map", "0.5.0").publish();
+    cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4").publish();
+    cargo_test_support::registry::Package::new("linked-hash-map", "0.6.0")
+        .yanked(true)
+        .publish();
+
+    let project = Project::from_template(current_dir!().join("in"));
+    let project_root = project.root();
+    let cwd = &project_root;
+
+    snapbox::cmd::Command::cargo_ui()
+        .arg("add")
+        .arg_line("linked_hash_map")
+        .current_dir(cwd)
+        .assert()
+        .success()
+        .stdout_eq(str![""])
+        .stderr_eq(file!["stderr.term.svg"]);
+
+    assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml
new file mode 100644
index 000000000..89e018f0e
--- /dev/null
+++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml
@@ -0,0 +1,9 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+edition = "2015"
+
+[dependencies]
+linked-hash-map = "0.5.4"
diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg
new file mode 100644
index 000000000..4766fc1a7
--- /dev/null
+++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg
@@ -0,0 +1,34 @@
+<svg width="740px" height="110px" xmlns="http://www.w3.org/2000/svg">
+  <style>
+    .fg { fill: #AAAAAA }
+    .bg { background: #000000 }
+    .fg-green { fill: #00AA00 }
+    .fg-yellow { fill: #AA5500 }
+    .container {
+      padding: 0 10px;
+      line-height: 18px;
+    }
+    .bold { font-weight: bold; }
+    tspan {
+      font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
+      white-space: pre;
+      line-height: 18px;
+    }
+  </style>
+
+  <rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
+
+  <text xml:space="preserve" class="container fg">
+    <tspan x="10px" y="28px"><tspan class="fg-green bold">    Updating</tspan><tspan> `dummy-registry` index</tspan>
+</tspan>
+    <tspan x="10px" y="46px"><tspan class="fg-yellow bold">warning</tspan><tspan class="bold">:</tspan><tspan> translating `linked_hash_map` to `linked-hash-map`</tspan>
+</tspan>
+    <tspan x="10px" y="64px"><tspan class="fg-green bold">      Adding</tspan><tspan> linked-hash-map v0.5.4 to dependencies</tspan>
+</tspan>
+    <tspan x="10px" y="82px"><tspan class="fg-green bold">     Locking</tspan><tspan> 1 package to latest compatible version</tspan>
+</tspan>
+    <tspan x="10px" y="100px">
+</tspan>
+  </text>
+
+</svg>
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/in/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/in/Cargo.toml
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/Cargo.toml
diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/dependency/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/in/dependency/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/src/lib.rs
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/mod.rs b/tests/testsuite/cargo_add/normalize_name_workspace_dep/mod.rs
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/mod.rs
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/mod.rs
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/out/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/out/Cargo.toml
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/Cargo.toml
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/Cargo.toml
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/Cargo.toml
diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/src/lib.rs
similarity index 100%
rename from tests/testsuite/cargo_add/path_normalized_name/in/primary/src/lib.rs
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/src/lib.rs
diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_workspace_dep/stderr.term.svg
similarity index 100%
rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/stderr.term.svg
rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/stderr.term.svg
diff --git a/tests/testsuite/cargo_add/yanked/in b/tests/testsuite/cargo_add/yanked/in
new file mode 120000
index 000000000..6c6a27fcf
--- /dev/null
+++ b/tests/testsuite/cargo_add/yanked/in
@@ -0,0 +1,1 @@
+../add-basic.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_add/yanked/mod.rs b/tests/testsuite/cargo_add/yanked/mod.rs
new file mode 100644
index 000000000..050943fe8
--- /dev/null
+++ b/tests/testsuite/cargo_add/yanked/mod.rs
@@ -0,0 +1,31 @@
+use cargo_test_support::compare::assert_ui;
+use cargo_test_support::current_dir;
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+use cargo_test_support::str;
+use cargo_test_support::Project;
+
+#[cargo_test]
+fn case() {
+    cargo_test_support::registry::init();
+    cargo_test_support::registry::Package::new("linked-hash-map", "0.5.0").publish();
+    cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4").publish();
+    cargo_test_support::registry::Package::new("linked-hash-map", "0.6.0")
+        .yanked(true)
+        .publish();
+
+    let project = Project::from_template(current_dir!().join("in"));
+    let project_root = project.root();
+    let cwd = &project_root;
+
+    snapbox::cmd::Command::cargo_ui()
+        .arg("add")
+        .arg_line("linked-hash-map")
+        .current_dir(cwd)
+        .assert()
+        .success()
+        .stdout_eq(str![""])
+        .stderr_eq(file!["stderr.term.svg"]);
+
+    assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_add/yanked/out/Cargo.toml b/tests/testsuite/cargo_add/yanked/out/Cargo.toml
new file mode 100644
index 000000000..89e018f0e
--- /dev/null
+++ b/tests/testsuite/cargo_add/yanked/out/Cargo.toml
@@ -0,0 +1,9 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+edition = "2015"
+
+[dependencies]
+linked-hash-map = "0.5.4"
diff --git a/tests/testsuite/cargo_add/yanked/stderr.term.svg b/tests/testsuite/cargo_add/yanked/stderr.term.svg
new file mode 100644
index 000000000..cf47fc90e
--- /dev/null
+++ b/tests/testsuite/cargo_add/yanked/stderr.term.svg
@@ -0,0 +1,31 @@
+<svg width="740px" height="92px" xmlns="http://www.w3.org/2000/svg">
+  <style>
+    .fg { fill: #AAAAAA }
+    .bg { background: #000000 }
+    .fg-green { fill: #00AA00 }
+    .container {
+      padding: 0 10px;
+      line-height: 18px;
+    }
+    .bold { font-weight: bold; }
+    tspan {
+      font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
+      white-space: pre;
+      line-height: 18px;
+    }
+  </style>
+
+  <rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
+
+  <text xml:space="preserve" class="container fg">
+    <tspan x="10px" y="28px"><tspan class="fg-green bold">    Updating</tspan><tspan> `dummy-registry` index</tspan>
+</tspan>
+    <tspan x="10px" y="46px"><tspan class="fg-green bold">      Adding</tspan><tspan> linked-hash-map v0.5.4 to dependencies</tspan>
+</tspan>
+    <tspan x="10px" y="64px"><tspan class="fg-green bold">     Locking</tspan><tspan> 1 package to latest compatible version</tspan>
+</tspan>
+    <tspan x="10px" y="82px">
+</tspan>
+  </text>
+
+</svg>