I don’t personally have a good reason to do this and I’m mostly just curious, but two reasons I can think of is if an organization prefers to host their own Crate server for their employees or has proprietary internal dependencies on their company network, or if Mozilla ever decides to shut down crates.io servers or gets sold to a consumer unfriendly company like Facebook or Google.

My questions are whether it’s possible to host Crates in a way that the compiler can understand (for example, if the crates.io backend is open source, or if you can replicate the functionality with a simple file server provided by software like Apache or Nignx), and whether you can configure the Rust compiler to recognize a custom URL to supplement or replace the standard crates.io server.

With JVM languages, you can easily add a URL to a Maven server that you host and pull jar files from there, even a HTTP simple file server can be used if you name the files and directories correctly. Is there a way to do the same in Rust?


Just to add that it is also possible to have it check out the source code from a Git repository: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories

So, you don’t even necessarily need to run a package registry (which might not be worth it for smaller companies)


Yes, cargo has support for alternate registries. crates.io is the default but you can switch it via global config or on a per-package basis. See https://doc.rust-lang.org/cargo/reference/registries.html for details on configuring cargo and setting up the registry itself.


It sounds like you’re looking for something called “vendoring” that was added to cargo in the last couple of years. If you want to store all your dependencies in some path local to your network, you can use the cargo vendor command. If you want an index like crates.io but not crates.io, then you want source replacemtnt.

Rust Programming
    • 0 user online
    • 2 user / day
    • 2 user / week
    • 12 user / month
    • 51 user / 6 month
    • 1.24K subscriber
    • 284 Post
    • 326 Comment
    • Modlog