Rbenv: Difference between revisions

From Wiki
Jump to navigation Jump to search
Line 11: Line 11:
Install the <code>rbenv</code> and <code>ruby-build</code> packages.  '''NOTE: Do this as deployment user in production!'''
Install the <code>rbenv</code> and <code>ruby-build</code> packages.  '''NOTE: Do this as deployment user in production!'''
<pre>
<pre>
apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev
apt-get install libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
cd
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/rbenv.git .rbenv

Revision as of 23:14, 20 November 2014

Overview: https://github.com/sstephenson/rbenv

Dependencies for building: https://github.com/sstephenson/ruby-build/wiki

Deploying to production server: https://github.com/sstephenson/rbenv/wiki/Deploying-with-rbenv


Setup

Install the rbenv and ruby-build packages. NOTE: Do this as deployment user in production!

apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev
apt-get install libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install -l | more  # show available versions
rbenv install 2.1.2      # choose one and install it
rbenv global 2.1.2
rebenv rehash
ruby -v

Installing Ruby Versions

This depends on having the ruby-build package.

# list all available versions:
$ rbenv install -l

# install a Ruby version:
$ rbenv install 2.0.0-p247

Downloads source, compiles, and stores the result in ~/.rbenv/versions/

rbenv rehash

$ rbenv rehash

Installs shims for all Ruby executables known to rbenv (i.e., ~/.rbenv/versions/*/bin/*). Run this command after you install a new version of Ruby, or install a gem that provides commands.

rbenv local

$ rbenv local 1.9.3-p327

Creates a .ruby-version file in the current directory.

rbenv versions

$ rbenv versions
  1.8.7-p352
  1.9.2-p290
* 1.9.3-p327 (set by /Users/sam/.rbenv/version)
  jruby-1.7.1
  rbx-1.2.4
  ree-1.8.7-2011.03

rbenv version

$ rbenv version
1.8.7-p352 (set by /Volumes/37signals/basecamp/.ruby-version)

rbenv which

$ rbenv which irb
/Users/sam/.rbenv/versions/1.9.3-p327/bin/irb