Skip to content

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

Closed
@arlosi

Description

@arlosi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions