0
0

More than 3 years have passed since last update.

brew doctor で ready to brew にするまでの道のり

Last updated at Posted at 2021-02-11

はじめに

brewにpythonをインストールしようと思ってbrew doctorを行ったところ、大量のエラーと格闘することになりました。
基本的にはエラー文に対処法が書いてあったり、エラー文の最初の1文を検索すれば解決方法が出てきますが、1つだけ手こずりました。
この記事はそのときの備忘録となります。

エラー内容

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  node

軽く翻訳すると、
「Cellar(樽置き場、樽群のインストール先のパス)にリンクされてないkeg(樽、Formula(調理法、パッケージの説明書や手順書)のインストール先パス)があります。樽をリンクしないままだとビルド時に問題が起こる可能性があります。それらの樽は一度ビルドすると正しく実行されません。brew link node を実行してください。」

とのことなので、brew link nodeを実行します。

$ brew link node

するとエラーが帰ってきます。

Error: Could not symlink share/doc/node/gdbinit
Target /usr/local/share/doc/node/gdbinit
already exists. You may want to remove it:
  rm '/usr/local/share/doc/node/gdbinit'

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

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

share/doc/node/gdbinitファイルにsymlink(シンボリックリンク(ファイルの別名のようなもの))が作れないから、対象のファイルを消すか上書きをするように書いてあります。
ここでは上書きします。

$ brew link --overwrite node

もちろん(?)エラーが帰ってきます。

Error: Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.

/usr/local/share/doc/nodeの書き込み権限が無いそうです。
ではこのディレクトリに移動して、権限を現在のユーザーに移動します。
その後に上書きします。

$ cd /usr/local/share/doc
$ sudo chown -R $USER node
$ brew link --overwrite node

期待通りエラーが帰ってきます。

Error: Could not symlink lib/dtrace/node.d
/usr/local/lib/dtrace is not writable.

/usr/local/lib/dtraceの書き込み権限がありませんと出ました。
直前のエラーと同じ内容です。
同じように解決します。

$ cd /usr/local/lib
$ sudo chown -R $USER dtrace
$ brew link --overwrite node

上書きが成功すると以下のメッセージが出ます。

Linking /usr/local/Cellar/node/15.8.0... 7 symlinks created.

もうエラーは無さそうなので、改めてbrew doctorを行います。

$ brew doctor
Your system is ready to brew.

あなたのシステムは醸造の準備が出来ています、と出ました。
お疲れさまでした、これでbrewが使えます。

終わりに

勉強がてらに初めてQiitaに投稿しましたが、とても勉強になりました。
人に教えるなどのアクティブラーニングは勉強内容の定着率が高いと言います。
今回は他人に見せる体で調べながら書きましたが、確かに実感できるほどにbrewやLinuxコマンドについて理解が深まったように感じます。

0
0
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
0
0