Elektrine lite

← Feed

@tisba@ruby.social

Post #3128015

2026-06-05 16:54 UTC

In a #Rust application, why would I specify a dependency version in Cargo.toml, if I don’t care about a specific version? Like using “*" by default. Cargo.lock would contain a concrete version, so stuff doesn't break randomly, everybody gets the exact same version. If there is an incompatible change, you can add constraints, like limiting it to version “2” for example.

Replies (1)

  • @diazona@techhub.social 2026-06-05 17:42

    @tisba@ruby.social I'm not that experienced with Rust, but in Python (which is fairly similar in this respect AFAIK) I would say you are correct, it's generally useful to make your dependency constraints as broad as possible in the non-lock file. That gives people wanting to install your package the most flexibility to combine it with other things in the same environment. Of course, if you know your package is not compatible with some version(s) of a dependency, you'd want to indicate that with an appropriate restriction - like, if you use a feature that was added in version 3, you'd restrict the version of that dependency to >=3.

    Open ##3720232