not found when compiling rust

I set up a rust dev environment via a flake and so far it worked fine. Now I’m trying to compile a rust program that uses the diesel postgres feature. Once the feature is included in the build, I get this error:

note: /nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: warning:, needed by /nix/store/79azl2c2q2c8agjq5w111638npgdvy81-postgresql-14.6-lib/lib/, not found (try using -rpath or -rpath-link)
          /nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: warning:, needed by /nix/store/79azl2c2q2c8agjq5w111638npgdvy81-postgresql-14.6-lib/lib/, not found (try using -rpath or -rpath-link)
          /nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: warning:, needed by /nix/store/79azl2c2q2c8agjq5w111638npgdvy81-postgresql-14.6-lib/lib/, not found (try using -rpath or -rpath-link)
          /nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/79azl2c2q2c8agjq5w111638npgdvy81-postgresql-14.6-lib/lib/ undefined reference to `ENGINE_init@OPENSSL_3.0.0'

The PKG_CONFIG_PATH is set, this is what my flake looks like:

  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    rust-overlay.url = "github:oxalica/rust-overlay";

  outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
    flake-utils.lib.eachDefaultSystem (system:
        overlays = [ (import rust-overlay) ];
        pkgs = import nixpkgs { inherit system overlays; };
        # rustVersion = pkgs.rust-bin.stable."1.63.0".default;
        rustVersion = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
        devShell =
          pkgs.mkShell {
            buildInputs = [
              (rustVersion.override {
                extensions = [ "rust-src" ];
                targets = [ "wasm32-unknown-unknown" ];
            shellHook = ''
              export PKG_CONFIG_PATH="${}/lib/pkgconfig";
              export CARGO=/run/current-system/sw/bin/cargo
              export CARGO_HOME=/home/knut/.cargo
              export PATH="/run/current-system/sw/bin:/home/knut/.cargo/bin:/home/knut/.nix-profile/bin:$PATH"
              export RUST_SRC_PATH="${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"

And when running pkg-config --libs-only-L openssl in the dev environment, I get the path


Is there any good advice on how to solve this?

It’s likely a recent regression in nipkgs/master. Should be fixed by build-support/cc-wrapper: revert "pass in non-existent --sysroot= to … by trofi · Pull Request #213185 · NixOS/nixpkgs · GitHub. Try nixpkgs/staging-next to make sure it’s already fine there.

1 Like

Thanks a lot, that fixed it