紳士なブログ

紳士すぎてすみません

Ruby2.0導入してみた

まずはHomebrewをupdate。

➜  ~  brew update
error: The following untracked working tree files would be overwritten by merge:
	Library/Formula/cmigemo.rb
	Library/Formula/pbrt.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



すると予期せぬエラーが。

http://br.0r2.info/2012/11/brew-update-mac.htmlを参考に対応してみる。

➜  ~  cd `brew --prefix`local git:(master) ✗ git fetch origin
 remote: Counting objects: 37, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 31 (delta 13), reused 27 (delta 10)
Unpacking objects: 100% (31/31), done.
From https://github.com/mxcl/homebrew
   3b16755..3fd8a47  gh-pages   -> origin/gh-pages
   0019042..9e8ffa9  go         -> origin/go
➜  local git:(master) ✗ git reset --hard origin/master
HEAD is now at 9a069ed vim 7.3.865local git:(master) ✗ brew update
Already up-to-date.



ひとまず問題解決。

というわけで早速rbenvのインストール可能なRuyバージョン確認。

➜  ~  rbenv install -l
Available versions:
  1.8.6-p383
  1.8.6-p420
  1.8.7-p249
  1.8.7-p302
  1.8.7-p334
  1.8.7-p352
  1.8.7-p357
  1.8.7-p358
  1.8.7-p370
  1.8.7-p371
  1.9.1-p378
  1.9.2-p180
  1.9.2-p290
  1.9.2-p318
  1.9.2-p320
  1.9.3-dev
  1.9.3-p0
  1.9.3-p125
  1.9.3-p194
  1.9.3-p286
  1.9.3-p327
  1.9.3-p362
  1.9.3-p374
  1.9.3-preview1
  1.9.3-rc1
  2.0.0-dev
  2.0.0-preview1
  2.0.0-preview2
  2.0.0-rc1
  jruby-1.5.6
  jruby-1.6.3
  jruby-1.6.4
  jruby-1.6.5
  jruby-1.6.5.1
  jruby-1.6.6
  jruby-1.6.7
  jruby-1.6.7.2
  jruby-1.6.8
  jruby-1.7.0
  jruby-1.7.0-preview1
  jruby-1.7.0-preview2
  jruby-1.7.0-rc1
  jruby-1.7.0-rc2
  jruby-1.7.1
  jruby-1.7.2
  maglev-1.0.0
  maglev-1.1.0-dev
  rbx-1.2.4
  rbx-2.0.0-dev
  rbx-2.0.0-rc1
  ree-1.8.6-2009.06
  ree-1.8.7-2009.09
  ree-1.8.7-2009.10
  ree-1.8.7-2010.01
  ree-1.8.7-2010.02
  ree-1.8.7-2011.03
  ree-1.8.7-2011.12
  ree-1.8.7-2012.01
  ree-1.8.7-2012.02



2.0.0-p0がないヽ(`Д´)ノ

というわけでrbenvをupgrade。

➜  ~  brew upgrade rbenv
Warning: A newer Command Line Tools for Xcode release is available
You should install the latest version from: http://connect.apple.com
==> Upgrading rbenv
==> Downloading https://github.com/sstephenson/rbenv/tarball/v0.4.0
######################################################################## 100.0%
==> Caveats
To enable shims and autocompletion add to your profile:
  if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

To use Homebrew's directories rather than ~/.rbenv add to your profile:
  export RBENV_ROOT=/usr/local/var/rbenv
==> Summary
 /usr/local/Cellar/rbenv/0.4.0: 31 files, 152K, built in 5 seconds


➜  ~  brew upgrade --HEAD ruby-build
Warning: A newer Command Line Tools for Xcode release is available
You should install the latest version from: http://connect.apple.com
Error: ruby-build-HEAD already installed



嫌な予感…。
ひとまず再度バージョン確認。

➜  ~  ruby-build --definitions
1.8.6-p383
1.8.6-p420
1.8.7-p249
1.8.7-p302
1.8.7-p334
1.8.7-p352
1.8.7-p357
1.8.7-p358
1.8.7-p370
1.8.7-p371
1.9.1-p378
1.9.2-p180
1.9.2-p290
1.9.2-p318
1.9.2-p320
1.9.3-dev
1.9.3-p0
1.9.3-p125
1.9.3-p194
1.9.3-p286
1.9.3-p327
1.9.3-p362
1.9.3-p374
1.9.3-preview1
1.9.3-rc1
2.0.0-dev
2.0.0-preview1
2.0.0-preview2
2.0.0-rc1
jruby-1.5.6
jruby-1.6.3
jruby-1.6.4
jruby-1.6.5
jruby-1.6.5.1
jruby-1.6.6
jruby-1.6.7
jruby-1.6.7.2
jruby-1.6.8
jruby-1.7.0
jruby-1.7.0-preview1
jruby-1.7.0-preview2
jruby-1.7.0-rc1
jruby-1.7.0-rc2
jruby-1.7.1
jruby-1.7.2
maglev-1.0.0
maglev-1.1.0-dev
rbx-1.2.4
rbx-2.0.0-dev
rbx-2.0.0-rc1
ree-1.8.6-2009.06
ree-1.8.7-2009.09
ree-1.8.7-2009.10
ree-1.8.7-2010.01
ree-1.8.7-2010.02
ree-1.8.7-2011.03
ree-1.8.7-2011.12
ree-1.8.7-2012.01
ree-1.8.7-2012.02
➜  ~  rbenv install 2.0.0-p0
ruby-build: definition not found: 2.0.0-p0



ruby-buildの最新版ではruby2.0は開発版しかないとのこと。。。
一度アンインストールしたほうがいいっぽかったので、いったんアンインストール。

➜  ~  brew uninstall ruby-build
Uninstalling /usr/local/Cellar/ruby-build/HEAD...



再度インストール。

➜  ~  brew install --HEAD ruby-build
Warning: A newer Command Line Tools for Xcode release is available
You should install the latest version from: http://connect.apple.com
==> Installing ruby-build dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.28.lion.bottle.tar.gz
  /usr/local/Cellar/pkg-config/0.28: 10 files, 636K
==> Installing ruby-build
==> Cloning https://github.com/sstephenson/ruby-build.git
Updating /Library/Caches/Homebrew/ruby-build--git
==> ./install.sh
  /usr/local/Cellar/ruby-build/HEAD: 72 files, 320K, built in 8 seconds



再度確認。

➜  ~  ruby-build --definitions
1.8.6-p383
1.8.6-p420
1.8.7-p249
1.8.7-p302
1.8.7-p334
1.8.7-p352
1.8.7-p357
1.8.7-p358
1.8.7-p370
1.8.7-p371
1.9.1-p378
1.9.2-p180
1.9.2-p290
1.9.2-p318
1.9.2-p320
1.9.3-dev
1.9.3-p0
1.9.3-p125
1.9.3-p194
1.9.3-p286
1.9.3-p327
1.9.3-p362
1.9.3-p374
1.9.3-p385
1.9.3-p392
1.9.3-preview1
1.9.3-rc1
2.0.0-dev
2.0.0-p0
2.0.0-preview1
2.0.0-preview2
2.0.0-rc1
2.0.0-rc2
2.1.0-dev
jruby-1.5.6
jruby-1.6.3
jruby-1.6.4
jruby-1.6.5
jruby-1.6.5.1
jruby-1.6.6
jruby-1.6.7
jruby-1.6.7.2
jruby-1.6.8
jruby-1.7.0
jruby-1.7.0-preview1
jruby-1.7.0-preview2
jruby-1.7.0-rc1
jruby-1.7.0-rc2
jruby-1.7.1
jruby-1.7.2
jruby-1.7.3
maglev-1.0.0
maglev-1.1.0-dev
rbx-1.2.4
rbx-2.0.0-dev
rbx-2.0.0-rc1
ree-1.8.6-2009.06
ree-1.8.7-2009.09
ree-1.8.7-2009.10
ree-1.8.7-2010.01
ree-1.8.7-2010.02
ree-1.8.7-2011.03
ree-1.8.7-2011.12
ree-1.8.7-2012.01
ree-1.8.7-2012.02



2.0.0-p0ある\(^o^)/

早速インストール

➜  ~  RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p0
title:8: parse error
Downloading ruby-2.0.0-p0.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
Installing ruby-2.0.0-p0...
Installed ruby-2.0.0-p0 to /Users/masumi/.rbenv/versions/2.0.0-p0

➜  ~  rbenv rehash
➜  ~  rbenv global 2.0.0-p0
➜  ~  ruby -v
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin11.4.0]



あれ…。。。


ここで指定したバージョンは~/.rbenv/versionファイルに書き込まれて保持されるけど、

このバージョンは.rbenv-versionか$RBENV_VERSIONによって上書きされるそう。
(.rbenv-versionか$RBENV_VERSIONのどちらも1.9.3p362になってたorz)

ひとまず以下で対応。

➜  ~  rbenv shell 2.0.0-p0
➜  ~  ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin11.4.0]
➜  ~  rbenv versions
  system
  1.9.3-p362
* 2.0.0-p0 (set by RBENV_VERSION environment variable)



ひとまずインストール完了。

広告を非表示にする