Pragmatic ball boy

iOSを中心にやってる万年球拾いの老害エンジニアメモ

【Rubyインストール編】Ruby素人が「たのしい開発スタートアップRuby」を実践

まずはインストール

環境:Mac OS X 10.7.4


$ ruby -v

ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]


Homebrewを使ってやってみます

brew install ruby
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Installing ruby dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
==> Patching
patching file vi_mode.c
patching file callback.c
patching file support/shobj-conf
patching file patchlevel
==> ./configure --prefix=/usr/local/Cellar/readline/6.2.2 --mandir=/usr/local/Cellar/readline/6.2.2
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you.
If you build your own software and it requires this formula, you'll need
to add its lib & include paths to your build variables:

    LDFLAGS  -L/usr/local/Cellar/readline/6.2.2/lib
    CPPFLAGS -I/usr/local/Cellar/readline/6.2.2/include
==> Summary
/usr/local/Cellar/readline/6.2.2: 30 files, 1.6M, built in 25 seconds
==> Installing ruby dependency: gdbm
==> Downloading http://ftpmirror.gnu.org/gdbm/gdbm-1.10.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gdbm/1.10 --mandir=/usr/local/Cellar/gdbm/1.10/share/man
==> make install
/usr/local/Cellar/gdbm/1.10: 10 files, 224K, built in 11 seconds
==> Installing ruby dependency: libyaml
==> Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libyaml/0.1.4
==> make install
/usr/local/Cellar/libyaml/0.1.4: 7 files, 328K, built in 10 seconds
==> Installing ruby
==> Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/ruby/1.9.3-p194 --enable-shared
==> make
==> make install
==> Caveats
NOTE: By default, gem installed binaries will be placed into:
  /usr/local/Cellar/ruby/1.9.3-p194/bin

You may want to add this to your PATH.
==> Summary
/usr/local/Cellar/ruby/1.9.3-p194: 14688 files, 74M, built in 4.3 minutes

うまくいったっぽい。
念のため確認してみると


$ ruby -v
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]

変わってない。。。だと。。。

以下本には書いていないこと。

$ which ruby
/usr/bin/ruby

/usr/bin/rubyのほうを見に行ってます。
ログをよくみると



NOTE: By default, gem installed binaries will be placed into:
  /usr/local/Cellar/ruby/1.9.3-p194/bin

You may want to add this to your PATH.


こっちにパスを張りやがれと書いてあるのでパスを追加します。
以下bashの例。

$ emacs .bash_profile

export PATH=/usr/local/Cellar/ruby/1.9.3-p194/bin:$PATH

$ source .bash_profile

$ echo $PATH

でちゃんとPATHが通ってるか確認

$ ruby -v

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

これでOK。