環境
Macbook Air(2016年モデル)
macOS Mojave
Homebrewインストール済み
状況
Homebrewを使って、rbenvをインストールしようと試みたところエラーが発生し、
$ brew doctor
で確認したところ以下のようなWarningが出現した。
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: The following directories do not exist:
/usr/local/opt
/usr/local/sbin
/usr/local/Cellar
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/opt /usr/local/sbin /usr/local/Cellar
sudo chown -R $(whoami) /usr/local/opt /usr/local/sbin /usr/local/Cellar
Warning: Broken symlinks were found. Remove them with `brew cleanup`:
/usr/local/bin/apm
/usr/local/bin/atom
/usr/local/bin/firebase
/usr/local/bin/npm
/usr/local/bin/npx
解決法
一つ目のWarningについて
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/opt /usr/local/sbin /usr/local/Cellar
sudo chown -R $(whoami) /usr/local/opt /usr/local/sbin /usr/local/Cellar
と書いてあるため、その通りに
sudo mkdir -p /usr/local/opt /usr/local/sbin /usr/local/Cellar
sudo chown -R $(whoami) /usr/local/opt /usr/local/sbin /usr/local/Cellar
とコマンドをコピペする。
何も反応はないが、とりあえずそのままでOK。
二つ目のWarningについて
Warning: Broken symlinks were found. Remove them with `brew cleanup`:
/usr/local/bin/apm
/usr/local/bin/atom
/usr/local/bin/firebase
/usr/local/bin/npm
/usr/local/bin/npx
と書いてあるため、その通りに
$ brew cleanup
とコマンドをコピペすると、
Pruned 5 symbolic links from /usr/local
と出てくる。
確認のために、もう一度
$ brew doctor
と打つと
Your system is ready to brew.
といってくれたのでエラーは解消できた。
$ brew install rbenv ruby-build
でインストールし
$ rbenv -v
で確認すると
rbenv 1.1.2
となり、インストールが完了。
まとめ
Homebrewを使っているなら、$ brew doctor
を使えば大体のことはわかる。