Pre-RFC Allow cargo build --dependencies-only

Hello, I have implemented this feature, by adding an additional package selection option, which I named --only-remote. It allows splitting the build into 2 stages:

  1. cargo build --only-remote -Z unstable-options
  2. cargo build

First execution downloads and compiles all non-local dependencies (including transitive), which makes the second run much faster, as it builds only local sources and links them.

The implementation is bit different than the implementation of the existing package selection options, namely --workspace, --package, --exclude, because if they exclude a package, they exclude also their dependencies. The --only-remote option on the other hand, if it decides to exclude a package, it keeps processing its dependencies. So this is a major difference at the implementation level. Nevertheless all the options can be safely combined.

More details at

Please let me know how to proceed. Do you want me to make a PR out of the implementation? I also wouldn't mind if somebody else would take my implementation and refine it to follow this project's standards for documentation and testing.

7 Likes