46

I try to do

brew install tmux

it installs, but, probably due to previous failed and not fully removed non-brew attempts to install both it and libevent, when try to use tmux I get

$ tmux
dyld: Library not loaded: /usr/local/lib/libevent-2.0.5.dylib
  Referenced from: /usr/local/bin/tmux
  Reason: image not found
Trace/BPT trap: 5

I tried to install libevent but I got:

$ brew install libevent
Warning: libevent-2.0.21 already installed, it's just not linked

so I tried

$ brew link libevent

but I got

Linking /usr/local/Cellar/libevent/2.0.21... 
Warning: Could not link libevent. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/libevent/2.0.21/include/event2/util.h
Target /usr/local/include/event2/util.h already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name
To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

so I tried

$ brew link --overwrite libevent

but I got

Linking /usr/local/Cellar/libevent/2.0.21... 
Warning: Could not link libevent. Unlinking...
Error: Permission denied - /usr/local/include/event2/util.h

so I tried

$ sudo brew link --overwrite libevent

Password:

but I got

Error: Cowardly refusing to `sudo brew link`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

I'm stuck.

8 Answers 8

24

Mine had the same problem.

$ tmux
dyld: Library not loaded: /usr/local/lib/libevent-2.0.5.dylib
Referenced from: /usr/local/Cellar/tmux/1.9a/bin/tmux
Reason: image not found
Trace/BPT trap: 5

Tried to install libevent but it was already there, not linked yet:

$ brew install libevent
Warning: libevent-2.0.21 already installed
$ brew link libevent
Warning: Already linked: /usr/local/Cellar/libevent/2.0.21
To relink: brew unlink libevent && brew link libevent

I solved it by doing exactly what was suggested above:

$ brew unlink libevent && brew link libevent
Unlinking /usr/local/Cellar/libevent/2.0.21... 4 links removed
Linking /usr/local/Cellar/libevent/2.0.21... 25 symlinks created
$ tmux -V
tmux 1.9a
1
  • 7
    That didn't work for me. I had to uninstall and reinstall. Commented Jun 19, 2017 at 14:16
70
brew uninstall --force tmux
brew install tmux

fixed it for me.

7
  • 6
    This worked for me, but without the need of --force. Commented May 15, 2017 at 12:03
  • 5
    Accepted answer didn't work in my case, but this did. Thanks Commented Aug 1, 2017 at 16:46
  • 1
    This worked for me as well (the accepted answer didn't work).. Commented May 23, 2018 at 5:20
  • 1
    only this worked! Commented Sep 7, 2019 at 13:07
  • 3
    No need for --force
    – spuder
    Commented Sep 10, 2019 at 21:50
6

I have the same issue with tmuxinator, And get that error in my case I upgraded tmux with:

brew upgrade tmux 
3

My tmux also started shooting this error recently. In my case simply calling brew upgrade tmux helped.

0

The answer was

 brew install pkg-config
 rm configure
 sh autogen.sh 
 ./configure 
 make
 make install

Also see http://whiletruecode.com/post/installing-iterm2-and-tmux-osx
but do the above instead of the broken link at the last step.

0

I tried the above steps but those did not work for me though. In my case I just did not have the missing version of libevent. I double, triple checked it but it seems that version isn't served by brew or someway.

What I did have is libevent-2.1.6.dylib. I made a symlink from libevent-2.0.5.dylib to the aforementioned file and tmux seems to work again. Perhaps tmux should be updated?

2
  • 1
    I understand that it seems i'm not answering the question. I had the exact same error message and symptoms. My problem, however, wasn't the badly linked libevent but just the a whole different version. My addition could help other people having the same issue i had.
    – Kozie
    Commented Feb 16, 2017 at 9:06
  • @Tetsujin actually, the OP didn't really ask a question, if we're going to split hairs. This answer solved it for me without losing my tmux session. Thanks Kozie for posting. Commented Dec 17, 2019 at 2:27
0

I got the same issue after updating macOS. To resolve

  • if you installed tmux from source code, than reinstall again, it will link the new libevent.
  • if used Homebrew run brew uninstall --force tmux; brew install tmux
0

I faced the issue and tried the above-mentioned solutions but it did not work. What I found out was that there was a weird dependency with openssl and since I installed openssl via pip it was not linked properly to /usr/local/opt and linking via brew was also not working. A simple solution was to uninstall both openssl and libevent via brew and reinstalling them via brew.

You must log in to answer this question.

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