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 install ignores --index when registry.default is set #11301

Closed
arlosi opened this issue Oct 27, 2022 · 0 comments · Fixed by #11302
Closed

cargo install ignores --index when registry.default is set #11301

arlosi opened this issue Oct 27, 2022 · 0 comments · Fixed by #11302
Labels
C-bug Category: bug

Comments

@arlosi
Copy link
Contributor

arlosi commented Oct 27, 2022

Problem

If a default registry is set via registry.default, then cargo install ignores the --index option and instead uses the default registry.

Steps

  1. Set registry.default to any registry name
  2. Attempt to do cargo install --index <URL> <CRATE> pointing to a different registry
  3. Cargo will ignore the --index argument and install from registry.default instead.

For example, the following should fail attempting to resolve my-registry-server, but instead it succeeds installing from crates.io.

CARGO_REGISTRY_DEFAULT=crates-io cargo install --index https://my-registry-server/ ripgrep

Possible Solution(s)

Reorder the chained if such that index has precedence over registry: https://github.com/rust-lang/cargo/blob/master/src/bin/cargo/commands/install.rs#L132

Notes

No response

Version

cargo 1.66.0-nightly (071eeaf21 2022-10-22)
release: 1.66.0-nightly
commit-hash: 071eeaf210708219a5a1b2c4728ca2f97df7f2ae
commit-date: 2022-10-22
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1q)
os: Ubuntu 22.04 (jammy) [64-bit]

Also occurs on stable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant