LoginSignup
16
13

More than 5 years have passed since last update.

Homebrewのエラー解消日記

Posted at

Homebrewってインストールやアンインストールが簡単にできるし、とっても便利ですよね!!
今回はそんなHomebrewを使っていながらずっと出ていたエラーを解消していきたいと思います。

動作環境

  • Mac OS High Sierra 10.13.4
  • Homebrew 1.5.14

本記事で用いている用語

  • user_name:自分のPCの名前

user_nameはコマンドの中にもあるので⌘+f(Mac)かcontrol+fで検索をかけた状態で見ていただくと、打ち間違いが減るかもしれないです。

現状の確認

brew doctor

brewコマンドにはbrew doctorという問題をチェックしてくれるコマンドがあります。とりあえずこれを叩いてみます。

bash
$ brew doctor
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: "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.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Users/user_name/.pyenv/shims/python2-config
  /Users/user_name/.pyenv/shims/python3.4m-config
  /Users/user_name/.pyenv/shims/python3.6m-config
  /Users/user_name/.pyenv/shims/python2.7-config
  /Users/user_name/.pyenv/shims/python-config
  /Users/user_name/.pyenv/shims/python3-config
  /Users/user_name/.pyenv/shims/python3.6-config
  /Users/user_name/.pyenv/shims/python3.4-config

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:
  heroku

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/etc/bash_completion.d/_brew_services

まぁ...出ますよね...
とりあえず簡単そうな部分から解消していきましょうか...

問題解消例

Broken symlinks were found. Remove them with brew prune:

bash
Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/etc/bash_completion.d/_brew_services

まずは簡単そうなこの部分ですね。とりあえずbrew pruneを叩きましょうかね。

bash
$ brew prune
Pruned 1 symbolic links and 2 directories from /usr/local

これでいいのかな??確認してみましょう。

bash
$ brew doctor
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: "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.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Users/user_name/.pyenv/shims/python2-config
  /Users/user_name/.pyenv/shims/python3.4m-config
  /Users/user_name/.pyenv/shims/python3.6m-config
  /Users/user_name/.pyenv/shims/python2.7-config
  /Users/user_name/.pyenv/shims/python-config
  /Users/u ser_name/.pyenv/shims/python3-config
  /Users/user_name/.pyenv/shims/python3.6-config
  /Users/user_name/.pyenv/shims/python3.4-config

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:
  heroku

おぉ!解消されてますね!引き続き解消していきます!

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:

続いてbrew linkですね。リストに挙げられているものを後ろにつけて実行します。

bash
$ brew link heroku
Linking /usr/local/Cellar/heroku/6.16.4...
Error: Could not symlink bin/heroku
Target /usr/local/bin/heroku
already exists. You may want to remove it:
  rm '/usr/local/bin/heroku'

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

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

rm '/usr/local/bin/heroku'これを実行すれば良さそうですね。

bash
$ ls /usr/local/bin/h*
/usr/local/bin/heroku

$ rm /usr/local/bin/heroku

$ ls /usr/local/bin/h*
ls: /usr/local/bin/h*: No such file or directory

これで再度brew linkを実行します。

bash
$ brew link heroku
Linking /usr/local/Cellar/heroku/6.16.4... 1 symlinks created

なんか良さそうですね!再び確認してみます!。

bash
$ brew doctor
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: "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.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Users/user_name/.pyenv/shims/python2-config
  /Users/user_name/.pyenv/shims/python3.4m-config
  /Users/user_name/.pyenv/shims/python3.6m-config
  /Users/user_name/.pyenv/shims/python2.7-config
  /Users/user_name/.pyenv/shims/python-config
  /Users/user_name/.pyenv/shims/python3-config
  /Users/user_name/.pyenv/shims/python3.6-config
  /Users/user_name/.pyenv/shims/python3.4-config

おぉ!順調ですね!!

"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以外からインストールされた*-configが気に入らないようです。
これを解消するのが一番大変でした。ですがなんとか解決記事を見つけれたので、詳細などは下記リンクから閲覧してみてください!!
【Homebrew】brew doctorのWarning対処方法 (その3) + envコマンドについて

下記のコマンドを打てばいいみたいですね!

bash
$ echo 'alias brew="env PATH=${PATH/\/Users\/user_name\/\.pyenv\/shims:/} brew"' >> ~/.bash_profile 

$ source ~/.bash_profile

これでまたまた確認してみます!

bash
$ brew doctor
Your system is ready to brew.

おぉ!綺麗になりましたね!!
今回は一旦ここで終了したいと思います!!
お疲れ様でした\\\٩( 'ω' )و ////

ちょっとした雑談

最近いろいろなところでエラーが出てその解消に余計に時間が割かれている気がします...もっと根本からの理解を深めて、自分自身で解決できるようになっていきたいものですね(^_^;)

参考にした記事

コマンドラインでbrew doctorすると警告だらけになっちゃった助けて
homebrewとは何者か。仕組みについて調べてみた
【Homebrew】brew doctorのWarning対処方法 (その3) + envコマンドについて

16
13
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
16
13