Question: How is the index.crates.io-xxxxxxxx directory name generated?

⚓ rust    📅 2025-04-26    👤 surdeus    👁️ 1      

surdeus

Hi Cargo team,

When working with crates stored in $CARGO_HOME/registry/src/,
I noticed that the source path is typically under a directory named like index.crates.io-xxxxxxxx.

However, on my machine, there are multiple such directories, for example:

  • index.crates.io-1949cf8c6b5b557f
  • index.crates.io-6f17d22bba15001f

I would like to understand:

  1. How exactly is the xxxxxxxx part (the hash suffix) generated?
  2. Why might there be multiple index.crates.io-* directories on the same machine?
  3. When Cargo needs to resolve a crate during build, how does it determine which index.crates.io-* folder to use?

From reading the source code, it seems related to CanonicalUrl and some hashing mechanism,
but I'm not entirely sure about the complete process.

Thank you very much for your help!

3 posts - 2 participants

Read full topic

🏷️ rust_feed