5

When using Cargo to build my Rust project, it downloads and compiles all the crates each time I trigger cargo build.

Is there no way to cache these libraries and speedup my build process?

I am running this on an Ubuntu 16.04 machine and using Docker to run my builds in. I guess there needs to be some mounted directory to share across builds which could solve my problem.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Rajeev Ranjan
  • 3,588
  • 6
  • 28
  • 52
  • 1
    Please provide more details (system, configuration, a reproducible and minimal example). Cargo usually caches crate downloads globally and builds per project(crate); at least on the systems I have been working on. – MB-F Jun 13 '18 at 08:26
  • Ok then. My builds are on dockers which must be causing the downloads again and again. – Rajeev Ranjan Jun 13 '18 at 08:33
  • This sounds plausible. I have no experience with docker, though. – MB-F Jun 13 '18 at 08:34
  • 4
    This is not an issue with Cargo, but Docker. You should provide the relevant bits of your `Dockerfile` for further context. – vijoc Jun 13 '18 at 09:34
  • This question has some useful/relevant info which might help: https://stackoverflow.com/questions/42130132/can-cargo-download-and-build-dependencies-without-also-building-the-application – Dave Challis Jun 13 '18 at 09:53

0 Answers0