LoginSignup
42
42

More than 5 years have passed since last update.

rbenv で Ruby を Debian にインストール

Last updated at Posted at 2012-05-15

RVM よりもシンプルな Ruby のバージョン切り替えシステムである rbenv を使って Ruby を Debian にインストールするメモ.

ビルドに必要なパッケージ一式を入れる.(RVM の notes を参考にした)

$ sudo 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

公式を参考にして rbenv をインストールする.

$ cd
$ git clone git://github.com/sstephenson/rbenv.git .rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

rbenv 単体では Ruby をインストールする機能がないので,ruby-build をインストールする.

$ mkdir -p ~/.rbenv/plugins
$ cd ~/.rbenv/plugins
$ git clone git://github.com/sstephenson/ruby-build.git

シェルを再起動する.端末を再起動するなり exec $SHELL するなり適当に.

rubyをインストールする.rbenv install とするとインストールできるrubyのバージョン一覧が表示されるので,欲しいバージョンを選ぶ.ここでは 1.9.3-p194 をインストールすることにしたとする.

$ rbenv install 1.9.3-p194
$ rbenv rehash

rbenv rehash はシンボリックリンクを張り直すコマンドで,rubyやgemのインストールによってコマンドが増えるたびに行う必要がある.

最後に,今インストールしたrubyを使用するように設定する.

$ rbenv global 1.9.3-p194
$ hash -r
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
42
42
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
42
42