Skip to content

Replacing default cargo registry results in failed build #919

@basbebe

Description

@basbebe

Describe the bug

I'm trying to use a local cache as a replacement for the default crates-io registry.
Local builds using cargo work (see config below).
However, building with crane fails with an error (see below) as soon as I add replace-with = "cargo-proxy" to my project's config.toml.

Reproduction

Using c6b4d53

./.cargo/config.toml

[registries]
cargo-proxy = { index = "sparse+https://myproxy.tld/repository/cargo/" }

[registry]
default = "cargo-proxy"

[source]

[source.crates-io]
replace-with = "cargo-proxy"

in flake.nix

          craneLibOrig = (crane.mkLib pkgs).overrideToolchain rustToolchain;
          craneLib = craneLibOrig.appendCrateRegistries [
            (craneLibOrig.registryFromSparse {
              indexUrl = "https://myproxy.tld/repository/cargo/";
              # where the sha256 is the sha256 of https://myproxy.tld/repository/cargo/config.json.
              configSha256 = "6589c57754423705767e15585a958332bfa859a6ca63d8fd99586e5837774b62";
              fetchurlExtraArgs = { };
            })
          ];

log:

building '/nix/store/3hvyk4hadvd8c64lmbjdm31djwhii79f-mycrate-deps-0.1.0.drv'...
mycrate-deps> cargoArtifacts not set, will not reuse any cargo artifacts
mycrate-deps> Running phase: unpackPhase
mycrate-deps> unpacking source archive /nix/store/hr4y6kql2pcfnakna14nan2dzrz70xgk-source
mycrate-deps> source root is source
mycrate-deps> Running phase: patchPhase
mycrate-deps> Executing configureCargoCommonVars
mycrate-deps> Running phase: updateAutotoolsGnuConfigScriptsPhase
mycrate-deps> Running phase: configurePhase
mycrate-deps> will append /build/source/.cargo-home/config.toml with contents of /nix/store/wdzfws3yg4qzk929xgp4pc2389lib03r-vendor-cargo-deps/config.toml
mycrate-deps> default configurePhase, nothing to do
mycrate-deps> Running phase: buildPhase
mycrate-deps> +++ command cargo --version
mycrate-deps> cargo 1.90.0 (840b83a10 2025-07-30)
mycrate-deps> +++ command cargo check --profile dev --locked --all-targets
mycrate-deps>     Updating `cargo-proxy` index
mycrate-deps> warning: spurious network error (3 tries remaining): [6] Could not resolve hostname (Could not resolve host: myproxy.tld)
mycrate-deps> warning: spurious network error (2 tries remaining): [6] Could not resolve hostname (Could not resolve host: myproxy.tld)
mycrate-deps> warning: spurious network error (1 try remaining): [6] Could not resolve hostname (Could not resolve host: myproxy.tld)
mycrate-deps> error: failed to get `[…]` as a dependency of package `[…]`
mycrate-deps>
mycrate-deps> Caused by:
mycrate-deps>   failed to query replaced source registry `crates-io`
mycrate-deps>
mycrate-deps> Caused by:
mycrate-deps>   download of config.json failed
mycrate-deps>
mycrate-deps> Caused by:
mycrate-deps>   failed to download from `https://myproxy.tld/repository/cargo/config.json`
mycrate-deps>
mycrate-deps> Caused by:
mycrate-deps>   [6] Could not resolve hostname (Could not resolve host: myproxy.tld)

Anything I'm missing / I could try?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions