LoginSignup
1
1

More than 5 years have passed since last update.

brew updateしても0.9.9から更新されなくなったので、手動で1.2.0にアップグレードした

Last updated at Posted at 2017-05-15

要約:
1. brew updateしても0.9.9からバージョンが変わらないときは、
2. 公式の README.mdのUpdate-bug に従って、
3. brewのローカルレポジトリを git reset --hard origin/master すれば1.2.0にアップグレードできる

現象

家ではMacBook Air 11inch Mid 2012をメインマシンとして使っているのだが、いつからか
brew updateしてもAlready up-to-date.としか返ってこなくなった。
Sierra対応時間かかるんだなぁ、と特に気に留めず、放ったらかしにしていた。

しかしOS更新してから半年以上経つぞと思い立って調べてみると、brewはバージョンは1.2に更新されていた。では、なぜうちのmacは更新されないのだろうか。

対策

How to upgrade? Brew stuck on 0.9.9を見ると、Sean Oldhamさんが2016年9月に公式README.mdを参照しながら解決策を示している。

2017年5月現在でも、brewの公式README.mdにはそのまま同じ対策が書かれていて、Homebrewのgitリポジトリを手動でリセットせよ、とのこと。

If Homebrew was updated on Aug 10-11th 2016 and brew update always says Already up-to-date. you need to run:
cd "$(brew --repo)" && git fetch && git reset --hard origin/master && brew update

実行

ステップバイステップでやってみた
文頭の % はコマンドプロンプト

必要のないファイルは事前に削除しておく

% brew cleanup
==> This operation has freed approximately 22.2G of disk space.

22GBって、どんだけ溜まっていたんだと愕然とした

次にバージョンの確認。2016年8月10日が最終更新日。

% brew --version
Homebrew 0.9.9 (git revision 06fe3; last commit 2016-08-10)
Homebrew/homebrew-core (git revision b163b; last commit 2016-08-10)

では、いよいよ手動アップグレード手順に入る。まず1コマンド目。

% cd "$(brew --repo)"

デフォルトのインストール先を使ったので、 /usr/local だった
ログを確認してみる。当然2016年8月10日。

% git log
commit 06fe347de97975dc01e726f87bf07a56a6fb713e
Author: Martin Afanasjew <martin@afanasjew.de>
Date:   Wed Aug 10 17:56:46 2016 +0200

    os/mac/ruby_keg: improve error reporting

    A failure to change a dylib ID or install name would previously cause a
    rather cryptic error message, that didn't include the name of the file
    that caused the failure, unless `--debug` was specified. Make sure to
    output this information in all cases before re-raising the exception.

次に2コマンド目、3コマンド目を実行

git fetch
git reset --hard origin/master

ログを確認してみると、たしかに更新されている事がわかる

% git log
commit ea8be174f6009bc9bdec67b13ca501b5b83fc4b8
Merge: 9889b42ec4 91efcb045e
Author: Mike McQuaid <mike@mikemcquaid.com>
Date:   Mon May 15 10:02:47 2017 +0100

    Merge pull request #2631 from GauthamGoli/audit_homepage_rubocop

    audit: Port audit_homepage method to rubocop and add tests

最後に、brew updateを実行すると、バージョン間の移行が行われる。大きな違いは、/usr/localではなく/usr/local/Homebrewを使うようになったこと。/usr/localの所有者はroot'wheelに戻して良いよと。

% brew update
Updated 6 taps (caskroom/cask, go-delve/delve, homebrew/core, homebrew/dupes, homebrew/fuse, osx-cross/avr).
==> New Formulae

...
==> Migrating HOMEBREW_REPOSITORY (please wait)...
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
  sudo chown root:wheel /usr/local

後は、brew upgradeすれば個々のソフトウェアもアップグレードされる

感想

  • アンインストールして新規インストールしようかと思ったが、調べてみてよかった
  • 日本語の文書は見つからなかったので、記事にしてみた
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1