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 doesn't work with local and directory registries #10926

Open
jonhoo opened this issue Aug 2, 2022 · 1 comment
Open

cargo add doesn't work with local and directory registries #10926

jonhoo opened this issue Aug 2, 2022 · 1 comment
Labels
C-bug Category: bug Command-add S-triage Status: This issue is waiting on initial triage.

Comments

@jonhoo
Copy link
Contributor

jonhoo commented Aug 2, 2022

Problem

cargo add is unable to add crates when told to use a registry that is a local or directory registry.

Steps

  1. cargo new --lib foo && cd foo
  2. cargo add libc
  3. cargo check
  4. mkdir .cargo
  5. cargo local-registry -s Cargo.lock local-registry > .cargo/config.toml
  6. sed '/itoa/d' Cargo.toml
  7. cargo add --registry local-registry itoa

Produces

error: no index found for registry: `local-registry`

Alternatively, if registry.default is set to local-registry in .cargo/config.toml, the same error occurs without passing --registry local-registry.

Possible Solution(s)

cargo add --registry foo bar should (assuming that bar exists in the registry foo) add

bar = { version = "...", registry = "foo" }

to Cargo.toml.

Ideally, I think if there's a source replacement of crates-io to foo, cargo add should be smart enough to realize the registry = "foo" part should not be necessary.

Notes

No response

Version

cargo 1.62.1 (a748cf5a3 2022-06-08)
release: 1.62.1
commit-hash: a748cf5a3e666bc2dcdf54f37adef8ef22196452
commit-date: 2022-06-08
host: aarch64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1n)
os: Amazon Linux AMI 2.0.0 [64-bit]
@jonhoo jonhoo added the C-bug Category: bug label Aug 2, 2022
@jonhoo
Copy link
Contributor Author

jonhoo commented Aug 2, 2022

Just for reference, the error originates here:

bail!("no index found for registry: `{}`", registry);

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-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants