Description
Let's say for example that:
- Your project depends on both libraries A and B.
- Library A depends on library
foo
0.1, and library B depends on libraryfoo
0.2 foo
0.1 depends onfoo-sys
0.1, andfoo
0.2 depends onfoo-sys
0.2foo-sys
has alinks
attribute in its Cargo.toml.
This raises an error from Cargo telling you that only one library can simultaneously link to the same native library.
More generally, whenever a library that has a links
attribute bumps its version in an incompatible way, and libraries start to use the new version, builds can break. This is notably what happened to the winapi
crate a few weeks ago and that broke half of the ecosystem. I'm personally opening this issue following a similar problem with openssl-sys
(foo
being openssl
, A
being postgres-rs
and B
being tiny_http
(but B
could also be hyper
)).
In addition to this, this means that if you randomly pick two crates from crates.io that work separately, you can't even be sure that you can use them at the same time.
A recent Cargo pull request changed the error message to suggest people to update or pin their dependencies. Forcing people to always use the latest version of a crate promotes the inverse of stability. Once you use a specific version of a library, you shouldn't be forced to update it just because another of your dependencies is incompatible with it. It also means that all the reverse dependencies of all -sys
crates must be immediately updated by their maintainers.
I see two solutions:
- Forcing crates with a
links
attribute to never ever bump their major version. This is obviously not practical. - Removing the restriction of the
links
attribute, so that multiple crates can link to the same native library. This is the less bad of the two.