Homebrewインストールのlinkエラーを修正する方法
問題
PostgreSQLをbrew installした時に以下のようなエラーに遭遇した。
$ brew install postgresql Warning: postgresql 10.1 is already installed, it's just not linked. You can use `brew link postgresql` to link this version.
どうやらリンクされていないらしく、warning文の指示に従うも、 (すでにpostgresqlがインストールされていたことは置いといて)
$ brew link postgresql Linking /usr/local/Cellar/postgresql/10.1... Error: Could not symlink share/man/man3/SPI_connect.3 /usr/local/share/man/man3 is not writable.
symlink(brewとpostgreSQLの中継役)が正しく設定されていないらしく、postgreSQLが(簡単には)利用できない状況にある。なので、writableになるよう設定を整備します。
解決策
- writableにしたいman3があるディレクトリに移動し、
chown
でman3のユーザー権限を現アカウントに委譲- 再び
brew link
してpostgres
を上書き保存
$ cd /usr/local/share/man $ sudo chown -R $USER man3 $ brew link --force postgres Linking /usr/local/Cellar/postgresql/10.1... Error: Could not symlink lib/pkgconfig/libecpg.pc /usr/local/lib/pkgconfig is not writable.
自分の場合、pkgconfigにも同様にsymlinkを設定する必要があったので、同様の解決策を試し、最後にきちんとリンクが通っているか確認します。
$ psql --version psql (PostgreSQL) 10.1
無事通りました。やっとpostgreSQLを使うスタートラインです。
最後に
brew doctor
をするとlinkエラーの起きているkeg(樽:生成材料)が特定できるので、上記の解決法を試せば、同様に改善されるかと思います。
$brew doctor 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: postgresql