6

My MAC OS is Yosemite 10.10, which has an old version of curl. I have installed Xcode and Xcode command line tools.

I run cURL with the "sudo" command as  “sudo curl”:
    sudo curl
    Password:
    curl: try 'curl --help' or 'curl --manual' for more information

However, when I run curl under the common user in the the terminal, it failed as follows:

  dyld: Library not loaded: /usr/lib/libcurl.4.dylib
  Referenced from: /usr/bin/curl
  Reason: Incompatible library version: curl requires version 7.0.0 or later, but libcurl.4.dylib provides version 5.0.0
  Trace/BPT trap: 5


  I also downloaded the curl version of 7.43, and installed in /usr/local/bin.

  —  "which curl”  shows “/usr/local/bin/curl” 
  —  otool shows:
     otool -L /usr/local/bin/curl
     /usr/local/bin/curl:
     /usr/local/lib/libcurl.4.dylib (compatibility version 8.0.0, current version 8.0.0)
     /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
     /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
     /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
     /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

   otool -L /usr/local/lib/libcurl.4.dylib 
    /usr/local/lib/libcurl.4.dylib:
    /usr/local/lib/libcurl.4.dylib (compatibility version 8.0.0, current version 8.0.0)
    /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
     /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
     /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
     /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

However, the curl still work with "sudo" but failed for common user, i.e.,

  dyld: Library not loaded: /usr/local/lib/libcurl.4.dylib
  Referenced from: /usr/local/bin/curl
  Reason: Incompatible library version: curl requires version 8.0.0 or later, but libcurl.4.dylib provides version 5.0.0
  Trace/BPT trap: 5

Meanwhile, the previous solution (trying to install curl with homebrew, getting "incompatible library version" for libcurl.4.dylib) did not work for my case.

-- More ----

Actually, the commands which seems to call the libcurl failed to run with the same information, e.g.:

--MacPorts:

  [user @MBK ~]$port

  dlopen(/opt/local/libexec/macports/lib/pextlib1.0/Pextlib.dylib, 6): Library not   loaded: /usr/lib/libcurl.4.dylib
   Referenced from: /opt/local/libexec/macports/lib/pextlib1.0/Pextlib.dylib
   Reason: Incompatible library version: Pextlib.dylib requires version 7.0.0 or later, but libcurl.4.dylib provides version 5.0.0
    while executing "load /opt/local/libexec/macports/lib/pextlib1.0/Pextlib.dylib"
    ("package ifneeded Pextlib 1.0" script)
    invoked from within "package require Pextlib 1.0"
    (file "/opt/local/bin/port" line 47)

-- Netcdf :

 [user@MBK ~]$ncdump 

  dyld: Library not loaded: /opt/local/lib/libcurl.4.dylib
   Referenced from: /opt/local/bin/ncdump
   Reason: Incompatible library version: ncdump requires version 8.0.0 or later, but libcurl.4.dylib provides version 5.0.0
  Trace/BPT trap: 5

Again, the commands with "sudo" work.

  • The output of type curl while you are using the user would be good to have. Also not sure if OSX includes ldd but give it a try using ldd /path/to/curl where the path is the result of type before. – Braiam Jul 07 '15 at 00:59
  • Thank you for your comments! type curl shows that "curl is hashed (/usr/local/bin/curl)", however, ldd can not be found in OSX. – flyonsnow Jul 07 '15 at 01:38
  • What are the permissions of /usr/local/lib/libcurl.4.dylib & /usr/local/lib & /usr/local ? – Basile Starynkevitch Jun 17 '17 at 08:44

6 Answers6

3

I had a similar issue, running

curl http://some.site

gave

dyld: Library not loaded: @rpath/libssl.1.0.0.dylib
Referenced from: /Users/samh/anaconda3/lib/libssh2.1.dylib
Reason: image not found

however, running conda install libssh2 fixed the problem. This makes no sense to me, since curl has worked on my machine for years... but at least it works now.

Sam H.
  • 131
  • 4
  • Thanks! It works! It happens to my freshly installed anaconda! Anaconda is truly a headache! I am wondering whether I can use the one installed by brew instead. – Po C. Feb 20 '19 at 02:20
  • Yes you can. Conda is just Python with a ton of helpful libraries. You can always brew install python, then create a venv, and install only the libs you need in that venv – Sam H. Mar 03 '19 at 22:03
  • I tried but it doesn't work for me. – Tan Duong Jun 06 '20 at 17:07
2

Ideally you should re-install curl via: brew reinstall curl so incompatible libraries are re-linked (.dylib files).

If won't help, double check values of DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH variables as misconfigured values can cause such problems (e.g. check your ~/.bashrc). Ideally unset them, otherwise if it's not set, try setting it as:

export DYLD_FALLBACK_LIBRARY_PATH="/usr/X11/lib:/usr/lib"

Similar issue: Dylibs and OS X.

kenorb
  • 20,988
0

Either you have two problems or one nasty one, to find out which type the command sudo sh -c 'type curl';type curl if both type commands show the same file you have the tough one, but probably you have two simpler ones: curl is installed twice and your dynamic linker is misconfigured.

hildred
  • 5,829
  • 3
  • 31
  • 43
  • 1
    I'm experiencing the same problem as flyonsnow expressed, and the output of the command you suggested outputs: curl is /usr/local/bin/curl curl is /usr/local/bin/curl, which is the "nasty" problem. Would you have any suggestions on how to solve this one? – Jared Jul 21 '15 at 23:04
  • @jared I am getting the same result from both commands as well. In my case, curl is /usr/bin/curl for each. Were you able to resolve this? If so, how? – Mike Eng May 02 '16 at 20:39
0

Seems like anaconda is installing its curl and breaking system's curl.

Type which curl and check where it is referencing to. If it is anaconda bins then you need to change PATH order.

I use zsh, and fixed it by changing

export PATH=~/anaconda3/bin:$PATH

to

export PATH=$PATH:~/anaconda3/bin

0

I recently moved from python 3.6 to 3.7. I am fairly certain that curl worked before then. The fact that conda install libssh2 fixes the problem makes me think that the python upgrade is what broke curl. This may be the explanation that Sam H is missing, i.e., "... makes no sense to me ...".

0

If you run into this issue after upgrading from openssl from 1.0 to 1.1, you need to upgrade openssh as well:

brew upgrade openssh

according to this post.

user10375
  • 101