Cargo config - alternate resistry and "checksums"

⚓ Rust    📅 2025-09-16    👤 surdeus    👁️ 1      

surdeus

So I am trying to setup my own private cargo server (crates.io-index mirror) in a closed environment.

My ${CARGO_HOME}/config.toml reads as follows

cat ~/.cargo/config.toml
[net]
# it only works with the git-cli, the libgit2 does not work for  us.
git-fetch-with-cli = true

[source]

[source.mirror]
git="ssh://git@gitlab.COMPANY.local/pure-testing/duane_cargo_index.git"
branch="master"

[source.crates-io]
replace-with = "mirror"

STEP 1: I create a new project with the command:

cargo new --bin foobar

STEP 2: I try to add 'libc' to the project and it fails with this error message:

   cd foobar
   cargo add libc

I get this error message:

$ cargo add libc
error: failed to load source for dependency `libc`

Caused by:
  Unable to update registry `crates-io`

Caused by:
  cannot replace `crates-io` with `mirror`, the source `crates-io` supports checksums, but `mirror` does not

  a lock file compatible with `crates-io` cannot be generated in this situation

My goal here is this: It is my understanding that the "crates.io-index" MUST be served from a GIT server only so I have put it in our gitlab server, and it is in the "master" branch, hence the "branch=master" in the cargo/config.toml file.

This is so fustrating .. I have not found an example that just works.

1 post - 1 participant

Read full topic

🏷️ Rust_feed