`cargo add` now looks up the latest version from crates.io


The cargo-edit project I announced last week has reached a quite important milestone in usability:

cargo add regex

now looks up the latest version on crates.io and adds regex = "0.1.41" to your Cargo.toml!

Here is how you can install it.

Other recently added features are cargo rm by rgardner, a fancier cargo ls by euclio and good starting point for integration tests by MrJohz.

This is but a pre-release version. Most likely, there are some bugs that need fixing (we don’t even have enough tests to find them all!) and there is some of the code (i.e., the parts I wrote) that could be written in a nicer way. It would be great if you could help us!


That’s awesome :smiley: I really hope these become part of the official Cargo distribution eventually. Super useful.

Have you though about adding the dependency as regex = "^0.1.41" instead? Seems like Rust in general is doubling down on semver, so choosing that as the default sounds like it would make sense to me.


IIRC, Cargo actually assumes the ^. If you want to have the fixed version, you’d have to write =0.1.41.


Awesome! Thanks for sharing this. I agree with Jonas that these commands should become part of Cargo itself. Cargo maintainers, take note!