This might be an unusual question, but I didn't see a simple way (yet) to just download a crate in a certain version from crates.io. For those crates that have a repository, I could go to the repository, but there is no guarantee that the versions are identical. I could also create a hello world program using the crate (by including it in Cargo.toml under [Dependencies]), enter cargo build, and then check my .cargo/registry/src/ directory, I guess.
But isn't there a simpler/direct way? Maybe like… a download button? Or something like cargo download (which doesn't seem to exist).
Perhaps it's there, and I just haven't noticed it yet?
Thanks! I just made myself this tiny shell script:
#!/bin/sh
mkdir tmp-download || exit 1
cd tmp-download || exit 1
curl -L https://crates.io/api/v1/crates/$1/$2/download | tar -xf -
mv $1-$2 ..
cd .. || exit 1
rmdir tmp-download
It might still be nice to have a way to download and add a crate to Cargo's local registry such that it won't be re-downloaded later, when I have a project depending on that version. I guess I could achieve that with a shell script as well (which creates a Cargo project, adds a dependency, builds the crate, and deletes everything). But I guess there is no such command to make that easier/faster?
% cargo install libc
Updating crates.io index
error: there is nothing to install in `libc v0.2.107`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.
Oh nice, cargo install indeed does populate my local registry, so I can use that when I want to peek into some crate's source code (assuming I trust the crate, as I think some installation code may be executed).