How does Cargo handle system-wide libraries and conflicts on a Gentoo system?


Hey folks,

I’m brand new to Rust and exploring the system.

I use Gentoo Linux, and since the distro compiles all libraries and programs it’s recommended not to use installation systems such as pip as the resulting library files may conflict with it.

That said, with pip you can specify the --user flag which installs the program/lib at a user level so that a library that pip uses doesn’t interfere with a system-side version.

How does Cargo handle this? Installing [](http://Way Cooler) i note that it’s pulling in dbus libraries that i already have installed system-wide. Where are dependencies put, and if i install 3 programs that use dbus am i going to have 3 copies of the same library + the system library?

Thank you,



Unless you are doing something special, it’s expected that cargo will always be run with user permissions, so everything that downloads lives under ~/.cargo folder.

Actually the same case is for installing rust through rustup.


Yes. But none of these versions will conflict with each other. The source code for cargo dependencies will be downloaded/cached into ~/.cargo/registry/src/ and the build artifacts will be stored somewhere in the target directory of your project folder (the folder containing Cargo.toml).

That’s how it works for normal rust dependencies.
It’s a little different for native library dependencies. Some projects will automatically download the source (generally C code), build it, and then statically link with it. Other projects will include code to automatically look for a system-installed version and use it if found.

way-cooler seems to depend on the dbus-rs crate, which is found here:
And the dbus-rs crate will require that you have a system-installed version of libdbus


Thank you @eminence and @ericho. That answers my questions nicely.

If i would end up with 3 copies of a library in that case, and disc space is tight, is there a way to reduce the duplication?