Override foreign dependencies with other versions?


I have a pet project thats getting large, and having worked on it on and off for over six months now the dependency graph has some rot issues, especially when you mix nightly and a hundred crates, some things break. Often.

Up to this point I’ve been forking every broken dependency / thing that doesn’t upgrade / thing that version mismatches, fixed the dependencies, and been stuck with a “git =” override on every crate that uses it.

Except in practice a ton of these broken crates / things that stop working do start working upstream in unreleased git. All I end up doing is forking crates to change the versions of their dependencies.

I’ve tried both the [patch] and [replaces] syntaxes in cargo.toml and neither can actually accomplish this. Best case scenario might be to make local repo clones of upstream and use cargo path syntax to override them?

A TLDR real example that drove me to try to fix this mess: Ring is broken on nightly with 1.12.1 right now (this breakage happened months after 1.12.1 was released). Fixes are in master. I have 3 independent crates all pointing to 1.12.1 right now which means all of them are broken (that and crates like ring are especially troublesome due to external linkage meaning you cannot float multiple versions of it - all my deps have to be lockstep on Ring versions). With what I know right now my only option is to fork everything, change all the ring = “1.12” lines to ring = { git = “…” } and point all my personal crates at the forks.

In isolation that was alright. The first 3 or so times. But now its just getting out of hand for me to have a dependency graph bloating with git forks of, currently, 15 crates. Across multiple personal projects. And then I regularly have to merge upstream commits into those forks and deal with merge conflicts.

So is there any way to override one version of a crate with another in the entire build system without having to fork everything?


I’m having the same issue with Ring. Have you perhaps found a better solution yet?