LoginSignup
2
2

More than 5 years have passed since last update.

久しぶりにHomebrew使ったら色々詰んだ。

Last updated at Posted at 2018-01-24

きっかけ

Macでtreeコマンドを使いたくなり、以下の方法があることを知った。

brew install tree 

しかし、brewを使うのが約半年ぶりのため、そこに至るまでに微々たる困難があった。どなたかの参考になるかと思い、ここに記録しておく。

Homebrewとは

パッケージマネージャー。パッケージのインストールやら、パッケージ同士の依存・競合関係やらを解決してくれるスグレもの。

実は先日LPIC101試験を受験したのだが、その出題範囲でもある「パッケージ管理システム」に近いものらしい。ちなみにこの試験はほとんど実機を使わずに合格出来た。何のための試験なのかと疑問に思っていたのだが、後々この知識が役に立つことになる。

インストール自体は以前通っていたプログラミングスクールで行っていたので、今回は割愛する。

Xcodeでつまづく

試しに何かコマンドを入力してみようとした。しかし拒否された。

$ brew -v
Error: You have not agreed to the Xcode license. Please resolve this by running:
  sudo xcodebuild -license accept

どうやらXcodeをアップデートした後に起こる現象であるらしい。

以下のコマンドを入力し、ライセンスを表示して同意したら進めた。(手っ取り早く終えるためにはqを入力する。その後agreeで同意。)

sudo xcodebuild -license

Homebrewの更新

brewコマンドは使えるようになったが、念のためアップデートも行った。以下の3つのコマンドを順に実行する。

$ brew update
$ brew upgrade
$ brew cleanup

そして最終チェック。ここでエラーになった。

$ brew doctor

エラーの原因

  • configが含まれているファイルが邪魔。

該当ファイルは全てMAMPがらみのファイルだったため、MAMP自体ををAppCleanerで削除した。(環境構築をMAMPに頼らず行おうと考えていたため、逆に良かった。)

今回は該当ファイルの削除という暴挙に出たが、本来ならば環境変数の設定で回避できるらしい。

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
  • 以前Homebrewでインストールしたはずのphpのリンクがおかしい。
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  php71

以下3つのコマンドを実行した。リンクを外し、ファイルを消し、デッドリンクを削除した。

$ brew unlink php71
$ rm -drf /usr/local/Cellar/php71/
$ brew prune

もう一度チャレンジ。これでよし。

$ brew doctor
Your system is ready to brew.

treeコマンド

brew doctorで警告が出ている状態でもインストール可能でした。しかしこのままの状態ではスッキリせず。勉強も兼ねて遠回りしました。

brew install tree 
2
2
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
2
2