UbuntuにRVMをインストール
RVM(Ruby Version Manager)
事前準備
curlとgitコマンドを使えるようにしておく必要があるのでそれぞれインストールします。
Curl
$ sudo aptitude install curl
Git
$ sudo aptitude install git-core
rvmインストール
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
~/.bashrc の最後に追記
$ vim ~/.bashrc # 最終行に追記 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
.bashrc 再読込
$ source ~/.bashrc
確認
$ rvm -v rvm 1.6.10 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
実際にRubyを入れる
notesを確認
$ rvm notes Notes for Linux ( DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick DISTRIB_DESCRIPTION="Ubuntu 10.10" ) NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X) This is the *original* / standard Ruby Language Interpreter 'ree' represents Ruby Enterprise Edition 'rbx' represents Rubinius bash >= 3.2 is required curl is required git is required (>= 1.7 recommended) patch is required (for ree and some ruby-head's). If you wish to install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head), then you must install and use rvm 1.8.7 first. If you wish to have the 'pretty colors' again, set 'export rvm_pretty_print_flag=1' in ~/.rvmrc. dependencies: # For RVM rvm: bash curl git # For Ruby (MRI & ree) you should install the following OS dependencies: ruby: /usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev # For JRuby (if you wish to use it) you will need: jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk # In addition to ruby: dependencies, ruby-head: subversion # For IronRuby (if you wish to use it) you will need: ironruby: /usr/bin/apt-get install curl mono-2.0-devel
※Ubuntu10.10で試してます。あとで11.04でもやってみる。
# For Ruby (MRI & ree) you should install the following OS dependencies:
ruby: /usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
とあるので、素直に入れる。
また、
# In addition to ruby: dependencies,
ruby-head: subversion
とあるので、Subversionも入れる。(けど、実際にruby-headから持ってくるときはgitだったように見えたような・・・)
$ sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
と
$ sudo aptitude install subversion
$ rvm package install readline
する。
ちょっとどのタイミングで直ったかわからないのですが、単純に rvm install 1.9.2 とかしてインストールはできたのですが、その後 irb すると readline がどうのこうのとメッセージが出たのでやりました。
ようやくRubyをインストールします。
最新版
rvm install ruby-head -C "--enable-shared=true,--with-opt-dir=/opt/local"
1.9.2系
rvm install 1.9.2 -C "--enable-shared=true,--with-opt-dir=/opt/local"
確認
$ rvm list rvm rubies ruby-head [ i386 ] ruby-1.9.2-p180 [ i386 ] ruby-1.8.7-p334 [ i386 ]
入ってますね。1.9.2を使ってみます。
$ rvm use 1.9.2 Using /home/atsm/.rvm/gems/ruby-1.9.2-p180 $ ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux] $ rvm list rvm rubies ruby-head [ i386 ] => ruby-1.9.2-p180 [ i386 ] ruby-1.8.7-p334 [ i386 ] $ irb ruby-1.9.2-p180 :001 > p "Hello World!" "Hello World!" => "Hello World!" ruby-1.9.2-p180 :002 > exit