When I try to use wget, I am getting this error message:

$: wget
dyld: Library not loaded: /opt/local/lib/libnettle.4.dylib
  Referenced from: /opt/local/bin/wget
  Reason: image not found
Trace/BPT trap: 5

I have reinstalled wget using homebrew (brew reinstall wget), I updated and upgraded my homebrew, however this hasn't helped.

In my /opt/local/lib/ folder I cannot find libnettle.4.dylib, however I do find /opt/local/lib/libnettle.6.dylib. I tried to solve the problem by simply symlinking from /opt/local/lib/libnettle.6.dylib to /opt/local/lib/libnettle.4.dylib. This didn't help either, but got me a new error message:

$ wget
dyld: Library not loaded: /opt/local/lib/libhogweed.2.dylib
  Referenced from: /opt/local/lib/libgnutls.28.dylib
  Reason: image not found
Trace/BPT trap: 5

When I run brew info wget, I get this output:

wget: stable 1.17.1 (bottled), HEAD
Internet file retriever
/usr/local/Cellar/wget/1.17.1 (9 files, 1.6M) *
  Built from source with: --with-debug
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/wget.rb
==> Dependencies
Build: xz ✔, pkg-config ✔
Recommended: openssl ✔
Optional: libressl ✔, pcre ✔, libmetalink ✔, gpgme ✔
==> Options

How can I fix this?


I think you have both MacPorts and Homebrew installed. MacPorts installs by default in /opt/local, whereas Homebrew installs in /usr/local. Since the command you are actually running is /opt/local/bin/wget, you probably have /opt/local/bin before /usr/local/bin in your PATH environment. Check it with:

$ echo $PATH

In such a case, any software installed with Homebrew is not used at all, if not called with its absolute path. So, try launching Homebrew's wget with its absolute path:

$ /usr/local/bin/wget

If it is working in this way, put /usr/local/bin as first folder in your PATH environment, by modifying ~/.profile or ~/.bash_profile file.

| improve this answer | |
  • Thanks a lot, this solved it! Indeed, I had macports installed and it had put /opt/local/bin in the $PATH, before '/urs/local/bin'. – TabeaKischka Apr 27 '16 at 9:33
  • Or use Macports' wget – mmmmmm Aug 28 '19 at 17:30

You could try updating the DYLD cache:

sudo update_dyld_shared_cache -root / -force

It is possible that the Dynamic Link Library cache hasn't updated to include the shared libraries which were installed when you installed wget.

| improve this answer | |
  • Thank you for your suggestion. I tried to run this command, however I got the error message update_dyld_shared_cache[37979] <Error>: Unable to unlink //var/db/spindump/OLDDSC-1EADBFCB-4F78-34F0-A9C8-F819511098EA: 1 Operation not permitted. However, the solution by gpz500 worked. – TabeaKischka Apr 27 '16 at 9:34
  • This worked when I ran wget --post-data and got a message about libidn2.0.dylib not being loaded. – Craig S. Anderson May 7 '19 at 6:54
  • did not work for me – Fernando Gabrieli Sep 16 '19 at 19:22

Both of the other solutions didn't work for me after I got this error (from a clean Homebrew install):

dyld: Library not loaded: /usr/local/opt/pcre/lib/libpcre.1.dylib
  Referenced from: /usr/local/bin/wget
  Reason: image not found
Abort trap: 6

However, issuing the following commands (found in https://stackoverflow.com/questions/50631185/homebrew-will-not-run-wget-command-library-not-loaded) worked fine:

brew uninstall --force pcre
brew install pcre
| improve this answer | |

On macports

sudo port install wget

would install the pcre2 dependency and the problem went away.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .