LoginSignup
12
13

More than 5 years have passed since last update.

MacをOS X Yosemite 10.10.1にしてからのHomebrewケア

Last updated at Posted at 2014-11-29

下調べせずにしたアップデートしてからの、特に問題らしきことは発生していなかったけど、brew updateしたらエラーやら警告がたくさんでてきたので、そのあたりのケアをこれからする

$ brew update
error: The following untracked working tree files would be overwritten by merge:
    Library/Formula/odt2txt.rb
    Library/Formula/omega.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

brew upgradeしたら以下のような感じ
エラーや警告が出た部分を抜粋

Warning: You have not agreed to the Xcode license.
Builds will fail! Agree to the license by opening Xcode.app or running:
    xcodebuild -license
(snip)
Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
(snip)
Error: Homebrew doesn't know what compiler versions ship with your version
of Xcode (6.1). Please `brew update` and if that doesn't help, file
an issue with the output of `brew --config`:
  https://github.com/Homebrew/homebrew/issues

xcode起動して規約に同意すればよさそうな気がしてきた...

brew doctorした時の警告が以下

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/bin/appcfg.py
  /usr/local/bin/bulkload_client.py
  /usr/local/bin/bulkloader.py
  /usr/local/bin/dev_appserver.py
  /usr/local/bin/remote_api_shell.py

Warning: You have leftover files from an older version of Xcode.
You should delete them using:
  /Developer/Library/uninstall-developer-folder

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:

    ruby

Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
    cd /usr/local/Library && git stash && git clean -d -f
  • brew prune
  • sudo /Developer/Library/uninstall-developer-folder
  • brew link ruby
  • cd /usr/local/Library && git stash && git clean -d -f

brew link rubyで以下のように表示され処理が中断されてしまったので、先にcd /usr/local/Library && git stash && git clean -d -fしといた

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
The current working directory doesn't exist, cannot proceed.

再度、brew link rubyしたら今度は、以下のようなエラー表示...

Linking /usr/local/Cellar/ruby/2.0.0-p0... 
Error: Could not symlink lib/ruby/gems
Target /usr/local/lib/ruby/gems
already exists. You may want to remove it:
  rm /usr/local/lib/ruby/gems

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

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

すでにディレクトリが存在しているからシンボリックリンクが貼れないと...
削除するか、無視して上書きするか、とりあえず確認するか

ということで、いきなり削除はなんなので、brew link --overwrite --dry-run rubyして対象を覗いてみた

確かにあるから削除してまえ、ということで、rm -fR /usr/local/lib/ruby/gemsで潔く削除

ということで、brew doctorで怒られた部分は解消したなずなので、再度、brew doctorを実行して、スッキリ... と思ったら、またもやシンボリックリンクが壊れているとか言われる... しかも先ほど、brew link rubyして綺麗になっているはずなのに...

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/lib/ruby/gems
  /usr/local/lib/ruby/site_ruby
  /usr/local/lib/ruby/vendor_ruby

ruby -vするとruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]って表示されるのに、実際のgem, site_ruby, vendor_rubyのリンク先が2.0.0だったりするのがおかしい?

lrwxr-xr-x   1 usename  admin   41 11 29 15:59 2.0.0 -> ../../Cellar/ruby/2.0.0-p0/lib/ruby/2.0.0
lrwxr-xr-x   1 usename  admin   40 11 29 15:59 gems -> ../../Cellar/ruby/2.0.0-p0/lib/ruby/gems
lrwxr-xr-x   1 usename  admin   45 11 29 15:59 site_ruby -> ../../Cellar/ruby/2.0.0-p0/lib/ruby/site_ruby
lrwxr-xr-x   1 usename  admin   47 11 29 15:59 vendor_ruby -> ../../Cellar/ruby/2.0.0-p0/lib/ruby/vendor_ruby

とりあえず、brew doctorの指示に従って、brew pruneしてみると、上記2.0.0のリンク以外が削除された...

ということで、もう怒られることはないだろうということで最後にもう一度、brew docrotしてYour system is ready to brew.と表示されたので万事OK

あとは、brew updateして、brew upgradeして、最新の状態にして環境整備(最新化)は完了〜

あっ、もう一つ、どうやらrubyの2.1.5が出ていたようなので、以下で追加インストールして、ruby環境も最新化して、再度、railsなんかも入れて... railsも4.1.8というのが出ていたようで、以前よりもバージョンアップして...

  • rbenv install 2.1.5
  • rbenv global 2.1.2
  • rbenv rehash
  • gem install bundler
  • gem install rails
  • gem install therubyracer
  • rbenv rehash

毎回これやるの面倒だなぁ...

と思ったところで、ついでに、今後のために2.1.2の頃に入れていたgemを追加してみた

  • gem install coffee-rails
  • gem install jquery-rails

gem install jquery-railsしたところでエラーが発生

ERROR:  Error installing jquery-rails:
    ERROR: Failed to build gem native extension.

    /Users/hayato/.rbenv/versions/2.1.5/bin/ruby extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions.  If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----

ということで、xcode-select --installを実行しようとしたら、自動でインストールを促すダイアログが表示されたので、OKして処理実行

無事、gem install jquery-railsが完了
続けて

  • gem install sass-rails

そのほか、2.1.2と2.1.5のgemで差分はあったけど無視
railsを実際に使う時に足りないものはインストールする

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