brew コマンドが動かなくなっていた件
brew
Published: 2018-07-22

目的

brew コマンドでインストールしようとしたところエラーが発生しました。

どうにかして使えるようにした時の記録です。

発生したエラー

tmux を利用しようと思い、インストールしてみたところ下記のエラーが発生しました。

$ brew install tmux
==> Installing dependencies for tmux: makedepend, libevent
==> Installing tmux dependency: makedepend
==> Downloading http://xorg.freedesktop.org/releases/individual/util/makedepend-1.0.5.tar.bz2
Already downloaded: /Library/Caches/Homebrew/makedepend-1.0.5.tar.bz2
==> Downloading http://xorg.freedesktop.org/releases/individual/proto/xproto-7.0.25.tar.bz2
Already downloaded: /Library/Caches/Homebrew/makedepend--xproto-7.0.25.tar.bz2
==> ./configure --disable-silent-rules --prefix=/private/tmp/makedepend20180701-31856-1cid5cf/makedepend-1.0.5/xproto
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/private/tmp/makedepend--xproto20180701-31856-1md6eg2/xproto-7.0.25':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

READ THIS: https://git.io/brew-troubleshooting

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:921:in `connect': Failed to connect to: https://api.github.com/search/issues?q=makedepend+repo:Homebrew/homebrew+in:title+state:open&per_page=100 (GitHub::Error)
SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: tlsv1 alert protocol version
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:921:in `block in connect'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:921:in `connect'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:313:in `open_http'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:709:in `buffer_open'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:210:in `block in open_loop'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:208:in `catch'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:208:in `open_loop'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:149:in `open_uri'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:689:in `open'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:30:in `open'
	from /usr/local/Library/Homebrew/utils.rb:354:in `open'
	from /usr/local/Library/Homebrew/utils.rb:384:in `issues_matching'
	from /usr/local/Library/Homebrew/utils.rb:412:in `issues_for_formula'
	from /usr/local/Library/Homebrew/exceptions.rb:145:in `fetch_issues'
	from /usr/local/Library/Homebrew/exceptions.rb:141:in `issues'
	from /usr/local/Library/Homebrew/exceptions.rb:184:in `dump'
	from /usr/local/Library/brew.rb:162:in `rescue in <main>'
	from /usr/local/Library/brew.rb:65:in `<main>'

brew が古くなったのかと思い、brew の update を試みました。

$ brew update
warning: unable to unlink .yardopts: Permission denied
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

$ sudo brew update
Password:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError)
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/Library/brew.rb:15:in `<main>'

解決するためにやったこと

困り果てていたところ、同じ問題に遭遇している人が解決策を書いていくれていました。

/usr/local のパーミッション の修正

$ ls -la /usr/local
total 96
drwxr-xr-x  23 root      wheel    782 11  4  2017 .
$ sudo chown $(whoami):admin /usr/local
$ ls -la /usr/local
total 96
drwxr-xr-x  23 hogehoge  admin    782 11  4  2017 .

Homebrew を更新

$ cd /usr/local/Library/Homebrew

$ git pull -q origin refs/heads/master:refs/remotes/origin/master

これで brew update が使えるようになりました。

$ brew update

参考