OSX curl error with unprivileged user dyld: Library not loaded

curlosx

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.

Best Answer

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.

Related Question