0
0

More than 3 years have passed since last update.

Rubyの開発環境を構築する際、様々なエラーが起こったので解消法をまとめてみた

Posted at

環境

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を使えば大体のことはわかる。

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