RVMでRubyをインストール

Rubyのバージョン管理RVMをつかってcentosrubyをインストールしてみました。

RVMのインストール

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable

パスの追加

export PATH=$PATH:/usr/local/rvm/bin/

~/.bashrcに書くとコマンドを打つ手間が省けます

Rubyをインストール

$ rvm install ruby-2.1.1
$ rvm install ruby-1.9.2-head

Rubyを使う

$ rvm use ruby-2.1.1

$ ruby -v

ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]

 無事インストールできました!

 

コマンド

インストールできるrubyのバージョン表示

$ rvm list -r

トラブルシューティング

エラー1

ERROR: Could not find 'which' command, make sure it's available first before continuing installation.

対処法:whichコマンドをインストール

$ yum install which

エラー2

In case of problems: http://rvm.io/help and https://twitter.com/rvm_io

 

  * WARNING: you are missing '/dev/fd' it is important for shell scripting used by RVM,

    You can fix it on most linux systems with:

 

      ln -sf /proc/self/fd /dev/fd

対処法:リンクを張る

$ ln -sf /proc/self/fd /dev/fd

エラー3

++ printf %b 'Error installing EPEL, it is required for libyaml-devel,

either there was an error installing EPEL package,

or there was problem checking if libyaml-devel is available / installed.\n'

Error installing EPEL, it is required for libyaml-devel,

either there was an error installing EPEL package,

or there was problem checking if libyaml-devel is available / installed.

++ return 127

Requirements installation failed with status: 127.

対処法:libyaml-develをインストール

$ yum install libyaml-devel

エラー4

bash-4.1# yum install libyaml-devel

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: ftp.iij.ad.jp

* extras: ftp.iij.ad.jp

* updates: ftp.iij.ad.jp

Setting up Install Process

No package libyaml-devel available.

Error: Nothing to do

 対処法:epelのリポジトリを追加

$ rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

エラー5

# rvm use ruby-1.9.2-head

 

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

 

You need to change your terminal emulator preferences to allow login shell.

Sometimes it is required to use `/bin/bash --login` as the command.

Please visit https://rvm.io/integration/gnome-terminal/ for a example.

対処法1:ログインしなおす

/bin/bash --login

対処法2:設定を読み込む

source "/usr/local/rvm/scripts/rvm"

http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function

エラー6

Warning! Requested ruby installation which requires another ruby available - installing one first.

 

To proceed rvm requires a ruby-1.9|ruby-2 compatible ruby is installed.

We attempted to install ruby automatically but it failed.

Please install it manually (or a compatible alternative) to proceed. 

対処法:2.1.1を先に入れる 

rvm install ruby-2.1.1

 

更新履歴

インストール手順が変わっていたので修正しました。(2015/02/14)

インストールできるrubyのバージョンを表示するコマンドを追加(2015/02/14)