Recursively gather all dependencies of a crate


#1

I’m trying to use a local fileserver for cargo, and serving packages to an unsuspecting build process requires anticipating in advance what packages will be requested. This is something I need to be able to do reasonably easily and thoroughly, since crates.io dependencies are everywhere; even rust-lang/rust/bootstrap has some dependencies:

 Downloading cmake v0.1.24
 Downloading filetime v0.1.10
 Downloading num_cpus v1.6.2
 Downloading libc v0.2.26
 Downloading rustc-serialize v0.3.24
 Downloading toml v0.1.30
 Downloading getopts v0.2.14
 Downloading gcc v0.3.51
   Compiling bootstrap v0.0.0 (file:///home/lampam/asd/clone/rust/src/bootstrap)
    Finished dev [unoptimized] target(s) in 10.5 secs

So: Given a directory with a Cargo.toml, I would like to be able to gather all unique (package, version) pairs that it could possibly depend on, recursively. And not necessarily in rust; any way in which I could obtain a text file in a reasonably structured format would do.

Right now I’m using this dumb little homegrown script that screenscrapes output from the cargo list feature added by cargo-edit. It gets me halfway, but it’s easily tripped up by various Cargo.toml features…


#2

You probably want cargo-vendor:


#3

I… that’s… that’s beautiful.