Patchelf and libcurl: "no version information available"

At work we use MongoDB, and it’s been cumbersome to upgrade it since it’s a non-free package and therefore not built by Hydra, and requires local compilation. So in my dev shell, I’ve written a derivation which fetches the pre-built Debian binary and uses autoPatchelfHook to patch it.

This works great except running the patched binary prints

mongod: /nix/store/cgmpl823df6sjgc9qbb9wrw379x8yvwk-curl-7.86.0/lib/libcurl.so.4: no version information available (required by mongod)

before proceeding normally.

I’ve tried ensuring that curl is on the binary’s PATH, to no effect.

Is there a way to fix this warning?

The package definition:

{ lib, stdenv, autoPatchelfHook, openssl_1_1, curl, ... }:
stdenv.mkDerivation rec {
  pname = "mongodb";
  version = "4.2.23";

  src = builtins.fetchurl {
    url =
      "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-${version}.tgz";
    sha256 = "0zs33gdgszq2qsafynxdxbw5d4al579mc2pw46zry4k54j0xyq3c";
  };

  dontConfigure = true;
  dontBuild = true;

  nativeBuildInputs = [ autoPatchelfHook ];

  buildInputs = [ openssl_1_1 curl ];

  autoPatchelfIgnoreMissingDeps = [
    "libpcap.so.0.8" # Only used by mongoreplay
  ];

  installPhase = ''
    install -m755 -D -t $out/bin bin/*
  '';
}
1 Like

Thanks for your derivation! It was really helpful to me :slight_smile:

Although the warning doesn’t really bug me I still was curious what’s causing it.
I’ve found the answer on StackOverflow here: tcl - error: curl: /usr/local/lib/libcurl.so.4: no version information available (required by curl) - Stack Overflow

Basically, mongodb expects the filename of libcur to include the full version not just the major version. So instead of libcurl.so.4 it should be libcurl.so.4.3.0.

It’s possible to build curl in a way that it is like this. The flag --enable-versioned-symbols needs to be added. Here’s how it can be overridden:

curl.overrideAttrs (old: {
    configureFlags = old.configureFlags ++ ["--enable-versioned-symbols"];
})

But this obviously means that curl needs to be rebuilt.

1 Like

Small update: The filename doesn’t seem to matter. The normal version of curl has the same files inside /lib as the patched one. It seems to be something inside the files that makes the difference.

Would be interesting if this could just be enabled by default…

Thanks for investigating! That’s helpful information to know.

Hello,

I have submitted a PR to fix this issue in nixpkgs.

Follow it at curl: enable flag `--enable-versioned-symbols` by drupol · Pull Request #336712 · NixOS/nixpkgs · GitHub

1 Like

@jkxyz Sorry for the @ but did you end up figuring this out? Dealing with a similar issue on a proprietary binary I’m trying to run using nix-ld.

Here’s my nix shell file if needed:

with import <nixpkgs> {};
# run with
# $ nix-shell ./masterpdfeditor.nix
  mkShell {
    NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [
      alsaLib
      freetype
      curl
      glib
      stdenv.cc.cc
    ];
    

    NIX_LD = builtins.readFile "${stdenv.cc}/nix-support/dynamic-linker";

    shellHook = ''
      ./voicepeak
    '';
  }

Then the error:

./voicepeak: /nix/store/2888pjmiry2b58gcjn0bv3p4g4d4il4k-curl-8.7.1/lib/libcurl.so.4: no version information available (required by ./voicepeak)

I just ignored it because it didn’t seem to cause any issues. It may also be fixed on new versions of nixpkgs. I don’t see the warning anymore when I run mongod. So you may need to update your nixpkgs.