I want to create a Cargo.lock file in a Rust project from Cargo.toml based on what was available on 22 Feb 2017. I need to make version selection compatible to what would happen on that specific day. (No, don't have a version controlled Cargo.lock around somewhere.)
I tried this to no avail:
Use the following lines in .cargo/config:
[source.mycrates]
registry = "file:///path/to/crates.io-index" # contains old checkout
[source.crates-io]
replace-with = "mycrates"
Nevertheless, cargo resolves dependencies in Cargo.toml to the newest ones available, not to the newest ones in the specified checkout.
How could I warp Cargo's version selection back in time?
This property is most desirable from applications and packages which are at the very end of the dependency chain (binaries). As a result, it is recommended that all binaries check in their Cargo. lock .
Cargo Watch watches over your project's source for changes, and runs Cargo commands when they occur. If you've used nodemon, guard, or entr, it will probably feel familiar. In the public domain / licensed with CC0. Uses Caretaker Maintainership.
Since you say you've already tried cloning the index, I'll assume you still have it lying around. For the benefit of other readers, the repository appears to be maintained in Git and is available at https://github.com/rust-lang/crates.io-index.
You'll need to tell cargo
to run with --frozen
so that it doesn't touch the network, q.v. the Cargo FAQ, and it will blow up if it thinks it needs to. If it has already downloaded stuff, you'll need to cargo clean
too, or otherwise nuke the cache.
If you don't already all of the packages you need in the checkout, you'll also need to download the specific versions you're interested in. Dissecting Crates.io: Bare Minimum Mirror has an explanation, which I'll summarize here in case the link blows up.
config.json
in the root of the Crates repo has the URLs for downloading packages, which are officially considered unstable, but works right now.The example from the
libc
crate used by the "gmjosack" shows a path of/api/v1/crates/libc/0.1.10/download
to download it, based upon thedl
key ofhttps://crates.io/api/v1/crates
inconfig.json
and the version available at the time of the post.
You'll probably need to script the downloads in order to build up your mirror. See also: Downloading Rust crates using a web browser on stackoverflow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With