How to resolve dependencie's version requirements

Viewed 116

I have dependency X in my project that depends on Z and dependency Y that also depends on Z but version requirements are different for X and Y. Also I use Z itself in my project and want it to be the latest version possible. So is there any way to resolve this conflict? e.g. specify that both versions must be downloaded by cargo or override the version that X or Y request

2 Answers

Unless the dependency in question is something super essential (such as an async runtime) AND there is no breaking change between your version and the older version you are good to go. Cargo does all the heavy lifting for you.

Basically cargo downloads both versions one to compile your crate and the other to compile the other crate.

In case of a runtime a mentioned above, code would still compile fine but you would get a runtime error so still code works compiles just fine and everything would work just fine if the code wouldnt try to access something thats not there any more.

This had happened before with tokio ecosystem. Some packages were updated to tokio 1x and some were still on 0x. Again this is an exception, cargo does all the management for you and most of the time you dont really need to worry about it.

This can be caused by a local cache issue. Try deleting the ~/.cargo/registry directory and try to build to project again.

Related