読者です 読者をやめる 読者になる 読者になる

RVMのインストール 〜 CentOS 5.6編

検証環境

CentOS release 5.6 (Final)
RVM 1.6.31



インストール

依存パッケージをインストールします

シェルのバージョンを確認します。

$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Curlをインストールします。検証環境ではインストール済みでした。

$ sudo yum install curl.x86_64 curl-devel.x86_64
...
Package curl-7.15.5-9.el5_6.3.x86_64 already installed and latest version
Package curl-devel-7.15.5-9.el5_6.3.x86_64 already installed and latest version
Nothing to do
$ curl --version
curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

Gitをインストールします。推奨バージョンは1.7以上です。

$ sudo yum install git.x86_64
...
==================================================================================================
 Package              Arch               Version                       Repository            Size
==================================================================================================
Installing:
 git                  x86_64             1.7.6-1.el5.rf                rpmforge             6.5 M
Installing for dependencies:
 perl-DBI             x86_64             1.52-2.el5                    base                 600 k
 perl-Git             x86_64             1.7.6-1.el5.rf                rpmforge              24 k

Transaction Summary
==================================================================================================
Install       3 Package(s)
Upgrade       0 Package(s)


RVMをインストールします
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Cloning into rvm...
remote: Counting objects: 5257, done.
remote: Compressing objects: 100% (2498/2498), done.
remote: Total 5257 (delta 3412), reused 3753 (delta 2051)
Receiving objects: 100% (5257/5257), 1.67 MiB | 1.05 MiB/s, done.
Resolving deltas: 100% (3412/3412), done.

  RVM:  Shell scripts enabling management of multiple ruby environments.
  RTFM: https://rvm.beginrescueend.com/
  HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
  
Installing RVM to /home/tetsuyai/.rvm/
    Correct permissions for base binaries in /home/tetsuyai/.rvm/bin...
    Copying manpages into place.


Notes for Linux ( CentOS release 5.6 (Final) )

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: yum install -y bash curl git libxslt # NOTE: For git you need the EPEL repository enabled

  # For Ruby (MRI & Ree) you should install the following OS dependencies:
  ruby: yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel ;
        yum install -y make bzip2 ;
        yum install -y iconv-devel # NOTE: For centos 5.4 final iconv-devel might not be available :(

  # For JRuby (if you wish to use it) you will need:
  jruby: yum install -y java

For rbx (Rubinius) more than 600MB of free RAM required.


  You must now complete the install by loading RVM in new shells.

  1) Place the folowing line at the end of your shell's loading files
     (.bashrc or .bash_profile for bash and .zshrc for zsh),
     after all PATH/variable settings:

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

     You only need to add this line the first time you install rvm.

  2) Ensure that there is no 'return' from inside the ~/.bashrc file,
     otherwise rvm may be prevented from working properly.

     
  This means that if you see something like:

    '[ -z "$PS1" ] && return'

  then you change this line to:

  if [[ -n "$PS1" ]] ; then

    # ... original content that was below the '&& return' line ...

  fi # <= be sure to close the if at the end of the .bashrc.

  # This is a good place to source rvm v v v
  [[ -s "/home/tetsuyai/.rvm/scripts/rvm" ]] && source "/home/tetsuyai/.rvm/scripts/rvm"  # This loads RVM into a shell session.

EOF - This marks the end of the .bashrc file

     Be absolutely *sure* to REMOVE the '&& return'.

     If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.

     Placing all non-interactive (non login) items in the .bashrc,
     including the 'source' line above and any environment settings.

  3) CLOSE THIS SHELL and open a new one in order to use rvm.
  

Installation of RVM to /home/tetsuyai/.rvm/ is complete.


tetsuyai,

Thank you very much for using RVM! I sincerely hope that RVM helps to
make your life both easier and more enjoyable.

If you have any questions, issues and/or ideas for improvement please
join#rvm on irc.freenode.net and let me know, note you must register
(http://bit.ly/5mGjlm) and identify (/msg nickserv <nick> <pass>) to
talk, this prevents spambots from ruining our day.

My irc nickname is 'wayneeseguin' and I am typically in #rvm during EDT daytime

If I do not respond right away, please hang around after asking your
question, I will respond as soon as I am back.  It is best to talk in
#rvm itself as then other users can help out should I be offline. The community
is growing and there are a lot of great people in it who gladly help if they can.

Be sure to get head often as rvm development happens fast,
you can do this by running 'rvm get head' followed by 'rvm reload'
or opening a new shell

  w&#10687;&#8255;&#10687;t

    ~ Wayne

RVMの依存パッケージに関する注意書きです。

bash >= 3.2 is required
curl is required
git is required (>= 1.7 recommended)
patch is required (for ree and some ruby-head's).

Rubinius、あるいはMRIの1.9.x-headをインストールする場合の注意書きです。

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.

RVMの依存パッケージに関する注意書きです。

  # For RVM
  rvm: yum install -y bash curl git # NOTE: For git you need the EPEL repository enabled

MRIとREEをインストールする場合の注意書きです。

  # For Ruby (MRI & Ree) you should install the following OS dependencies:
  ruby: yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel ;
        yum install -y make bzip2 ;
        yum install -y iconv-devel # NOTE: For centos 5.4 final iconv-devel might not be available :(

注意書きに従って、依存するライブラリをインストールします。

# sudo yum install gcc-c++.x86_64 patch.x86_64 readline.x86_64 readline-devel.x86_64 zlib.x86_64 zlib-devel.x86_64 libyaml-devel.x86_64 libffi-devel.x86_64 openssl-devel.x86_64 make.x86_64 bzip2.x86_64 iconv-devel.x86_64;
...
==================================================================================================
 Package                    Arch             Version                     Repository          Size
==================================================================================================
Installing:
 libffi-devel               x86_64           3.0.9-1.el5.rf              rpmforge            16 k
 libyaml-devel              x86_64           0.1.3-1.el5.rf              rpmforge            12 k
 patch                      x86_64           2.5.4-31.el5                base                63 k
 readline-devel             x86_64           5.1-3.el5                   base               159 k
Installing for dependencies:
 libffi                     x86_64           3.0.9-1.el5.rf              rpmforge            94 k
 libtermcap-devel           x86_64           2.0.8-46.1                  base                56 k
 libyaml                    x86_64           0.1.3-1.el5.rf              rpmforge           117 k

Transaction Summary
==================================================================================================
Install       7 Package(s)
Upgrade       0 Package(s)

JRubyの依存パッケージに関する注意書きです。

  # For JRuby (if you wish to use it) you will need:
  jruby: yum install -y java

Rubiniusを動かすには600MB以上の空きメモリが必要です。

For rbx (Rubinius) more than 600MB of free RAM required.

.bashrcの末尾に次の一行が追加されていることを確認します。確認したら、.bashrcを読み直します。

FILE: ~/.bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
$ source ~/.bashrc
$ echo $rvm_path
/home/tetsuyai/.rvm
$ type rvm | head -1
rvm is a function


Rubyをインストールします

MRIの1.8.7と1.9.2をインストールします。

$ sudo find / -name "readline"
/usr/include/readline
$ rvm install 1.8.7 -C "--with-readline-dir=/usr/include/readline"
$ rvm install 1.9.2 -C "--with-readline-dir=/usr/include/readline"



補足

Readline

最初、MRIの1.8.7(1.9.2でも)をインストールしてirbを起動すると、以下のようなメッセージが表示されました。

Readline was unable to be required, if you need completion or history install readline then reinstall the ruby.
You may follow 'rvm notes' for dependencies and/or read the docs page http://rvm.beginrescueend.com/packages/readline/ . Be sure you 'rvm remove X ; rvm install X' to re-compile your ruby with readline support after obtaining the readline libraries.
no such file to load -- readlin

コンパイル時にReadlineを認識できていないようです。Readlineを認識させるには二種類の方法があります。

yumでインストールしたReadlineの場所を教える

コンパイルオプションを使って、yumでインストールしたReadlineの場所を指定します。Readlineの場所がわからない場合はfindコマンドを使って検索するのがいいでしょう。

$ sudo yum install readline.x86_64 readline-devel.x86_64
$ sudo find / -name "readline"
/usr/include/readline
$ rvm install 1.8.7 -C "--with-readline-dir=path/to/readline"

RVMでReadlineをインストールする

yumでインストールしたReadlineを置き換えたくはないが、Rubyからは異なるバージョンのReadlineを使いたい、など複数Readlineを使い分けたい場合は、RVMを使ってReadlineをインストールすることもできます。コンパイルオプションにはReadlineの場所として$rvm_path/usrを指定します。

$ rvm package install readline
$ rvm install 1.9.2  --with-readline-dir=$rvm_path/usr

https://rvm.beginrescueend.com/packages/readline/