Search code examples
rustnixosrust-diesel

Crate with diesel and mysql dependencies no longer compiles against mariadb after upgrading NixOS to 20.03


My crate, which depends on diesel with the mysql feature enabled, no longer compiles after upgrading my system from NixOS 19.09 to 20.03. It seems the only significant change is an update of the mariadb-server package from 10.2.17 to 10.3.18. There is no change to the Rust toolchain etc. (it's statically pinned in nix-shell to nightly 2020-04-20).

The very long compiler message starts with:

warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit code: 1

What should I do?


Solution

  • This build script that tells Cargo to link the crate using the compiler's flag `-lmariadb solved the issue:

    fn main() {
        println!("cargo:rustc-link-lib=mariadb");
    }
    

    Update 2020-05-01

    Actually the issue could be solved in mysqlclient-sys crate.