Rubyの準備 for OS X

  • 投稿日:
  • by
  • カテゴリ:
Mac OS X 10.8 にインストールされているのは古いRuby。
$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
1.9 を必要としたので、どうしようかなと思って調べていたら rbenv というツールで
Rubyのバージョン管理ができるようだ。


ということで、セットアップ開始。

Homebrew があった方が楽そうなので、まずはこれから。
Rubyがインストールできればよいので X11 や JDK はインストールしない。
(特にJDKはインストールしたくない。)
Xcode と Command Line Tools for Xcode はインストール済みなので省略。

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
==> The following directories will have their group set to admin:
/usr/local/.

Press ENTER to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/.

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/.
==> Downloading and Installing Homebrew...
remote: Counting objects: 109750, done.
remote: Compressing objects: 100% (30862/30862), done.
remote: Total 109750 (delta 78967), reused 106957 (delta 77959)
Receiving objects: 100% (109750/109750), 13.74 MiB | 2.13 MiB/s, done.
Resolving deltas: 100% (78967/78967), done.
From https://github.com/mxcl/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at bd309c4 connect: fix audit warning
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help
$ brew doctor
Your system is ready to brew.
$
続いて、rbenv, ruby-build のインストール。
$ brew install rbenv ruby-build
==> Downloading https://github.com/sstephenson/rbenv/archive/v0.4.0.tar.gz
######################################################################## 100.0%
==> Caveats
To use Homebrew's directories rather than ~/.rbenv add to your profile:
  export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion add to your profile:
  if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
==> Summary