Help us understand the problem. What is going on with this article?

Homebrewがいつの間にか動かなくなっていたので直した

More than 3 years have passed since last update.

久しぶりに Homebrew を使ってインストールしようとしたら、うまく動かなくなっていました。

$ brew update
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
/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>

Permission denied とか出ていて、何が起きたのかよくわからなかったので色々調べていたら、OS X を El Capitan にするときに SIP の影響で「Homebrewを先にインストールしておけ」という記事を思い出しました。なのでそちら方面で調べていたら、/usr/local のパーミッションの修正で直りました。

$ ls -la /usr/local
total 96
drwxr-xr-x  18 root    wheel    612 10 17 04:41 .

所有者が root になっていたので自分自身に修正。
# $(whoami) は fish とかだと動かないので一旦 bash などへ

$ sudo chown $(whoami):admin /usr/local

$ ls -la /usr/local
total 96
drwxr-xr-x  18 kazuya  admin    612 10 17 04:41 ./

手動でHomebrewを更新。

$ cd /usr/local/Library/Homebrew

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

正しく動くようになりました。 :clap:

$ brew update
Already up-to-date.

追記: 2016-02-28
今日別のマシンで試したらこんな素敵なエラーが出ました。

$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした