NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.19k stars 14.2k forks source link

Mavericks cannot bootstrap due to missing curl dependencies #5606

Closed jwiegley closed 9 years ago

jwiegley commented 9 years ago

Using a virgin Mavericks machine, nix-env -i curl fails to configure with the following error:

checking run-time libs availability... failed
configure: error: one or more libs available at link-time are not available run-time. Libs used at link-time: -lssh2 -lssh2 -lssl -lcrypto -lldap -lz
builder for ‘/nix/store/cy8ybjfj0xd8jbpcj9yqi3lk4knvywzk-curl-7.39.0.drv’ failed with exit code 1

The workaround to get things started is to change all-packages.nix:

--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -940,7 +940,7 @@ let

   curl = callPackage ../tools/networking/curl rec {
     fetchurl = fetchurlBoot;
-    zlibSupport = true;
+    zlibSupport = false;
     sslSupport = zlibSupport;
     scpSupport = zlibSupport && !stdenv.isSunOS && !stdenv.isCygwin;
   };

Once all of the necessary libraries are built by Nix this isn't needed anymore, so I think the right solution is simply to increase the dependency set for curl when zlibSupport is true.

Pinging @edolstra @lovek323

jwiegley commented 9 years ago

Or maybe not zlibSupport, but one of those *Support flags is missing a needed dependency.

jwiegley commented 9 years ago

It seems all the libraries are present. I will keep digging.

jwiegley commented 9 years ago

The underlying error is:

dyld: Library not loaded: libz.so.1.2.8
  Referenced from: /private/var/folders/sq/906k53jd3w7cd5rf9fpc0g_00000gn/T/nix-build-curl-7.39.0.dr
v-0/curl-7.39.0/./conftest
  Reason: image not found
jwiegley commented 9 years ago

Here is a fix that works for me:

--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -33,6 +33,8 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
     rm src/tool_hugehelp.c
+  '' ++ stdenv.lib.optionalString stdenv.isDarwin '';
+    export DYLD_LIBRARY_PATH=${zlib}/lib:$DYLD_LIBRARY_PATH
   '';

   # make curl honor CURL_CA_BUNDLE & SSL_CERT_FILE
@@ -41,12 +43,19 @@ stdenv.mkDerivation rec {
   '';

   configureFlags = [
+      ( if zlibSupport then "--with-zlib=${zlib}" else "--without-zlib" )
       ( if sslSupport then "--with-ssl=${openssl}" else "--without-ssl" )
       ( if scpSupport then "--with-libssh2=${libssh2}" else "--without-libssh2" )
     ]
     ++ stdenv.lib.optional c-aresSupport "--enable-ares=${c-ares}"
     ++ stdenv.lib.optional gssSupport "--with-gssapi=${gss}";

+  installPhase = stdenv.lib.optionalString stdenv.isDarwin ''
+    for prog in $out/bin/*; do
+      wrapProgram "$prog" --prefix DYLD_LIBRARY_PATH : "${zlib}/lib"
+    done
+  '';
+
   CXX = "g++";
   CXXCPP = "g++ -E";
jwiegley commented 9 years ago

This is not the right fix; see #5608.