Ubuntu 11.10 で RVM

Ruby on Railsを用いたWebアプリケーション開発用にRVMを導入する。

RVMのインストール

rvm: Ruby Version Managerに書いてあるとおりインストールする。
まずは必要なソフトウェアをインストール。

% sudo aptitude install curl git-core

その後、RVMをインストールする。

sudo  bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

これで/usr/local/rvm 以下にrvmがインストールされる。


現在のユーザーをrvmグループに加える。

% sudo addgroup USERNAME rvm

公式サイトのInstallationによると、/usr/local/rvm/ 以下にインストールしている場合は、/etc/profile.d/rvm.sh が実行され、 /usr/local/rvm/scripts/rvm が読み込まれるはずなのだけど、どうもうまくいかない。

RVM:Integrating rvm with gnome-terminalによると、gnome-terminalが原因らしい。ここに書いてあるとおりに設定する。

  1. gnome-terminalの「編集」ー>「プロファイルの設定」ー>「タイトルとコマンド」ー>「ログインシェルとしてコマンドを実行する」をチェックする。
  2. .zshrcの末尾に「source /etc/profile.d/rvm.sh」を加える。

gnome-terminalを立ち上げ直す。以下のようになっていたら成功。

% type rvm
rvm is a shell function

Ruby 1.9.3のインストール

依存関係を調べる。

% rvm requirements

Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.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 >= 4.1 required
curl is required
git is required (>= 1.7 recommended)
patch is required (for ree and some ruby-head's).

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.

NOTE: To all Multi-User installers - DO NOT forget to add your users to the 'rvm' group.
      The installer does not auto-add any users to the rvm group. Admins must do this.
      Group memberships are ONLY evaluated at login time. Log them out, then back in.

Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
  ruby: /usr/bin/apt-get install build-essential 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 automake libtool bison subversion

# For JRuby, install the following:
  jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
  jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk

# For IronRuby, install the following:
  ironruby: /usr/bin/apt-get install curl mono-2.0-devel

よって以下をインストールする。

% sudo aptitude install build-essential 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 automake libtool bison subversion

インストールする。

% rvm install 1.9.3-head

rubyの切り替え。

% ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

% rvm use 1.9.3-head
Using /usr/local/rvm/gems/ruby-1.9.3-head

% ruby -v
ruby 1.9.3p5 (2011-11-30 revision 33907) [i686-linux]