Usually this is great. You avoid dependency hell while only trading off some compiled binary size. Sometimes it fails when a package must have only one version, e.g. because you're passing around data types from that package to/from your dependencies which use the old version, but part of rust/cargo's trick is that types drawn from different versions of the same package are distinct types. So you get a compile-time type check error.
Solution: the widget package maintainer pushes out a final 1.x release which itself depends on widget=2, and is simply a shim that re-exports the API. This semver-violating trickery is basically a stealth upgrade that forces all upstream widget=1 pegged crates onto the new widget=2 release branch.
This trick is generic and relevant outside of rust, at least so far as other package managers user semver-aware dependency management.
If your imports look like:
A -> B -> C
A -> C
In the scenario you’re describing, can’t C just stay on older versions of B if the maintainers don’t want to upgrade A? Why would the maintainers of A try to force C to upgrade? Said another way, why would C upgrade A via this trick while pretending they didn’t upgrade?Using the trick, the last v1 package is a facade that constructs the old interface using the new package. To provide equivalent functionality, you basically have to do the same thing.
But in the real world there are times when major versions are bumped without breaking changes. E.g. a bunch of crates maintained as part of a single project with a uniform versioning scheme.
A A
/ \ / \
Cv2 B into | B
\ \ \
Cv1 \ Cv1
\ /
Cv2
Suppose some exported symbol, X, didn't change from Cv1 to Cv2. In the former, A gets two copies of X depending on which path it took up the dependency tree. In the latter, there's only one copy since both paths terminate in the same place.In the case of Go I'm not sure if it's important that v1 specifically re-export the v2; I think it would work equally well either way. But it's at least very similar.
Is this trick relevant outside of rust?