Hatena::ブログ(Diary)

katsusukeの日記 このページをアンテナに追加 RSSフィード Twitter

2010-12-21

Ruby Version Manager(RVM) を使って Mac OSX Snow Leopard にRuby 1.9 をインストールする

前回の失敗を踏まえてRuby Version Manager(RVM)をつかってMacにRuby 1.9の導入を試みる

RVMはgem を使ってもインストールすることが出来るようだが、いまいちやり方が分からなかったのでgitを使ってソースを取ってくる

$ git clone git://github.com/wayneeseguin/rvm.git
$ cd rvm/
$ ./install

.bashrcの最後のほうに以下を追加

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

でターミナルを再起動

$ rvm -v
rvm 1.1.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
$ rvm info
system:
  system:
    uname:       "Darwin mksc-no-mac-pro-2.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
  rvm:
    version:      "rvm 1.1.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"
  homes:
    gem:          "not set"
    ruby:         "not set"
  binaries:
    ruby:         "/opt/local/bin/ruby"
    irb:          "/opt/local/bin/irb"
    gem:          "/opt/local/bin/gem"
    rake:         "/opt/local/bin/rake"
  environment:
    PATH:         "/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/shimizu/bin:/Users/shimizu/.rvm/bin:/Users/shimizu/.rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""

インストールは成功している模様

サポートしている環境を一覧する

$ rvm list known_strings
ruby-head
ruby-1.9.2-rc2
ruby-1.9.2-rc1
ruby-1.9.2-preview3
ruby-1.9.2-preview1
ruby-1.9.2-p0
ruby-1.9.2-head
ruby-1.9.1-p429
ruby-1.9.1-p378
ruby-1.9.1-p243
ruby-1.9.1-head
ruby-1.8.7-p302
ruby-1.8.7-head
ruby-1.8.6-p399
ruby-1.8.6-head
ree-1.8.7-head
ree-1.8.7
ree-1.8.6-head
ree-1.8.6
rbx-head
rbx-1.1.1
rbx-1.1.0
rbx-1.0.1
maglev-head
maglev-24864
macruby-nightly
macruby-head      
macruby-0.8 
jruby-head
jruby-1.5.6
jruby-1.4.0
jruby-1.3.1
jruby-1.2.0
ironruby-head
ironruby-1.0-rc2
ironruby-0.9.3
goruby

Rubyのページの一番普通にDLできるバージョンが1.9.2-p0 なのでそれをインストールする

$ rvm install 1.9.2-p0
/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0, this may take a while depending on your cpu(s)...

ruby-1.9.2-p0 - #fetching 
ruby-1.9.2-p0 - #downloading ruby-1.9.2-p0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8296k  100 8296k    0     0  1743k      0  0:00:04  0:00:04 --:--:-- 2036k
ruby-1.9.2-p0 - #extracting ruby-1.9.2-p0 to /Users/shimizu/.rvm/src/ruby-1.9.2-p0
ruby-1.9.2-p0 - #extracted to /Users/shimizu/.rvm/src/ruby-1.9.2-p0
ruby-1.9.2-p0 - #configuring 
ruby-1.9.2-p0 - #compiling 
ruby-1.9.2-p0 - #installing 
ruby-1.9.2-p0 - updating #rubygems for /Users/shimizu/.rvm/gems/ruby-1.9.2-p0@global
ruby-1.9.2-p0 - updating #rubygems for /Users/shimizu/.rvm/gems/ruby-1.9.2-p0
ruby-1.9.2-p0 - adjusting #shebangs for (gem).
ruby-1.9.2-p0 - #importing default gemsets (/Users/shimizu/.rvm/gemsets/)
Install of ruby-1.9.2-p0 - #complete 
$ rvm info

system:

  system:
    uname:       "Darwin mksc-no-mac-pro-2.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.1.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"

  homes:
    gem:          "not set"
    ruby:         "not set"

  binaries:
    ruby:         "/opt/local/bin/ruby"
    irb:          "/opt/local/bin/irb"
    gem:          "/opt/local/bin/gem"
    rake:         "/opt/local/bin/rake"

  environment:
    PATH:         "/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/shimizu/bin:/Users/shimizu/.rvm/bin:/Users/shimizu/.rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""
$ which ruby
/opt/local/bin/ruby
$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
$ rvm use 1.9.2
Using /Users/shimizu/.rvm/gems/ruby-1.9.2-p0$ rvm info

ruby-1.9.2-p0:

  system:
    uname:       "Darwin mksc-no-mac-pro-2.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.1.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p0"
    date:         "2010-08-18"
    platform:     "x86_64-darwin10.5.0"
    patchlevel:   "2010-08-18 revision 29036"
    full_version: "ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]"

  homes:
    gem:          "/Users/shimizu/.rvm/gems/ruby-1.9.2-p0"
    ruby:         "/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0"

  binaries:
    ruby:         "/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0/bin/ruby"
    irb:          "/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0/bin/irb"
    gem:          "/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0/bin/gem"
    rake:         "/Users/shimizu/.rvm/gems/ruby-1.9.2-p0/bin/rake"

  environment:
    PATH:         "/Users/shimizu/.rvm/gems/ruby-1.9.2-p0/bin:/Users/shimizu/.rvm/gems/ruby-1.9.2-p0@global/bin:/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/shimizu/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/shimizu/bin"
    GEM_HOME:     "/Users/shimizu/.rvm/gems/ruby-1.9.2-p0"
    GEM_PATH:     "/Users/shimizu/.rvm/gems/ruby-1.9.2-p0:/Users/shimizu/.rvm/gems/ruby-1.9.2-p0@global"
    MY_RUBY_HOME: "/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0"
    IRBRC:        "/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0/.irbrc"
    RUBYOPT:      ""
    gemset:       ""
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]
$ gem -v
1.3.7
$ which gem
/Users/shimizu/.rvm/rubies/ruby-1.9.2-p0/bin/gem

おお!できたっぽい。

今後メインを1.9.2-p0にしたいので .bashrcに

rvm use 1.9.2-p0 > /dev/null

を追加する。

railsのインストール。gem はユーザー配下にインストールされるので一般ユーザーでインストール

$ gem install rails
$ rails -v
Rails 3.0.3

参考にさせて頂いたサイト

http://runeleaf.wordpress.com/2010/02/07/ruby-rvm%E3%81%A7ruby%E3%81%A8%E3%81%8Bgem%E3%81%A8%E3%81%8Brake%E3%81%A8%E3%81%8B%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E5%88%87%E3%82%8A%E6%9B%BF%E3%81%88/

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/katsusuke/20101221/1292899455