Skip to content

Cargo.lock: source field does not reflect the actual source of packages #15663

Open
@aaronjwood

Description

@aaronjwood

Problem

I'm in an environment where there are two Artifactory instances, one that serves up config.json in a correct way for mirroring and another that doesn't. The instance that's correct looks like this:

{
  "dl": "https://<REDACTED>/artifactory/api/cargo/cargo-remote/v1/crates",
  "api": "https://<REDACTED>/artifactory/api/cargo/cargo-remote"
}

The other one looks like:

{
  "dl": "https://static.crates.io/crates",
  "api": "https://crates.io"
}

We're trying to migrate between these. Our CI environment has no WAN access so the registry which is serving an incorrect config.json ended up breaking things. This was wildly unexpected and it was only until config.json was scrutinized along with some verifications (more on that below) that gave away the indication of what was happening. Regardless of which environment was used the project's lock file always contained source = "registry+https://github.com/rust-lang/crates.io-index".

Since the lock file gives no indication of where things are actually coming from I had to prove this in a long-winded way. Basically setting 127.0.0.1 localhost github.com static.crates.io crates.io in /etc/hosts and running cargo build on a project showed that the packages were coming from the Artifactory instance serving the correct config.json while packages were coming from upstream when using the Artifactory instance serving the incorrect config.json.

Since source in the lock file is misleading at best and policy-breaking at worst I'm assuming this is not intended, especially since there doesn't seem to be any reasonable way for folks to know where things are actually coming from. If our CI had WAN access we'd be going out to the upstream registry to get everything and never know it (unless you assume some network monitoring team will flag it one day) which is a serious issue for us.

Steps

No response

Possible Solution(s)

Have source reflect where things are actually coming from, which is defined in the registry's index config.json.

Notes

No response

Version

cargo 1.87.0 (Homebrew)
release: 1.87.0
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 system)
libcurl: 8.7.1 (sys:0.4.80+curl-8.12.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 15.5.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-source-replacementArea: [source] replacementC-bugCategory: bugS-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions