darudaru

だるだるしてるエンジニア

Macにtmuxをインストールしようとしたらlibeventのエラーで手こずった

自分のMacにtmuxをhomebrewでインストールしようとしたら、一発でうまくいかずにかなり手こずってしまいました。会社のMacでインストールしたときはすんなりできたので、MacのOSの違いとかが原因なのかもしれないです。

環境

  • Mac OSX 10.9.5

tmuxをインストールする

homebrewでtmuxをインストールします。

$ brew install tmux
==> Installing dependencies for tmux: libevent
==> Installing tmux dependency: libevent
==> Downloading https://homebrew.bintray.com/bottles/libevent-2.0.22.mavericks.bottle.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "libevent"
Download failed: https://homebrew.bintray.com/bottles/libevent-2.0.22.mavericks.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "libevent"
Download failed: https://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz

libeventのダウンロードに失敗しました。libeventのインストールを試みます。

$ brew install libevent
==> Downloading https://homebrew.bintray.com/bottles/libevent-2.0.22.mavericks.bottle.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "libevent"
Download failed: https://homebrew.bintray.com/bottles/libevent-2.0.22.mavericks.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "libevent"
Download failed: https://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz

同じエラーで失敗しました。libeventをダウンロードする元のURLが変わってしまっていて、404になっているようです。 現在のlibeventがダウンロードできるURLに変更します。

$ brew edit libevent

urlを「https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gzに変更して、保存してから再度libeventのインストールをしてみます。

$ brew install libevent

エラーが出ることなくlibeventがインストールできたようです。再度tmuxをインストールを試みます。

$ brew install tmux
Error: You must `brew link libevent' before tmux can be installed

エラーが出ました。指示通り、「brew link libevent」を実行します。

$ brew link libevent
Linking /usr/local/Cellar/libevent/2.0.22...
Error: Could not symlink bin/event_rpcgen.py
Target /usr/local/bin/event_rpcgen.py
already exists. You may want to remove it:
rm '/usr/local/bin/event_rpcgen.py'

To force the link and overwrite all conflicting files:
brew link --overwrite libevent

To list all files that would be deleted:
brew link --overwrite --dry-run lib event

エラーが出ました。/usr/local/bin/event_rpcgen.py のファイルが既に存在していたので、指示通り削除し、brew link libeventを再実行したのですが、また別のファイルを削除するように指示が出たので思い切って強制的に上書きのオプションをつけて実行します。

$ brew link --overwrite libevent

エラーが出ずに実行ができたので、再々度tmuxをインストールしてみます。

$ brew install tmux

インストールできました!

brew install libeventを実行する前に、公式サイトからtarファイルをダウンロードしてコンパイルする方法も試したのですが、うまくいかずにhomebrewでのインストールに切り替えて行いました。そのためか、中途半端にファイルがダウンロードされてlibeventのbrew link libeventで失敗したように思います。始めから全部homebrewでやればよかったね…libeventがhomebrewでインストールできるのかが分からなかったんです…。