Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo add wrongly autocorrects crates when vendored #14309

Closed
TheNeikos opened this issue Jul 26, 2024 · 2 comments
Closed

cargo add wrongly autocorrects crates when vendored #14309

TheNeikos opened this issue Jul 26, 2024 · 2 comments
Labels
C-bug Category: bug Command-add S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@TheNeikos
Copy link
Contributor

Problem

When using cargo add while vendored it 'autocorrects' the crate name, even for quite far string distances and for crates that are included in the vendored directory!

(I also think that the distance it corrects to, is too far for such a short string. Given that adding a crate to your Cargo.toml is quite consequential wrt to access rights, having an unknown one being installed is not ideal. Especially if not vendored.)

A quick demonstration:

✦ ❯ cargo add uuid --features v4,serde
warning: translating `uuid` to `nom`
      Adding nom v7.1.3 to dependencies.
error: unrecognized features for crate nom: serde, v4
no features available for crate nom
✦ ❯ ls vendor/uuid/
Cargo.toml  LICENSE-APACHE  LICENSE-MIT  README.md  src

This confused me for a moment, when I then tried 'cargo update' it finally dawned on me that it was my vendoring of packages that caused this odd output.

Steps

  1. Vendor your dependencies (cargo vendor)
  2. Update the .cargo/ file
  3. Run cargo add for a crate that exists

Possible Solution(s)

No response

Notes

No response

Version

✦ ❯ cargo version --verbose
cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: NixOS 24.11.0 [64-bit]
@TheNeikos TheNeikos added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 26, 2024
@epage
Copy link
Contributor

epage commented Jul 26, 2024

This looks to be a duplicate of #10729 which was fixed in #13281 which was released with 1.78.

Could you reproduce with a newer version of Cargo to verify if this particular case is still an issue?

@epage epage added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. Command-add and removed S-triage Status: This issue is waiting on initial triage. labels Jul 26, 2024
@TheNeikos
Copy link
Contributor Author

TheNeikos commented Jul 28, 2024

🤦‍♀️ You are completely right, this is exactly the same situation/symptom. I can't check it directly, but reading through it, that seems to be the case.

Sorry for the noise, I really keep forgetting what the latest version is and did not read further to see the date line.

I'll close and re-check once I can. If it somehow is different, I'll reopen.


NB: The reason your linked issue didn't show up in my search, was because I looked for the command-add tag and vendor. But github did not match that to vendored :/ Oh well, maybe someone will find mine then 🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-add S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants