Rbenv: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(20 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{lowercase title}} | {{lowercase title}} | ||
https://github.com/sstephenson/rbenv | 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 | Deploying to production server: https://github.com/sstephenson/rbenv/wiki/Deploying-with-rbenv | ||
== Upgrade to latest version == | |||
<pre> | |||
cd ~/.rbenv | |||
git pull | |||
cd plugins/ruby-build | |||
git pull | |||
</pre> | |||
== Setup == | == Setup == | ||
Install the <code>rbenv</code> and <code>ruby-build</code> packages. '''NOTE: Do this as deployment user in production!''' | Install needed packages '''as root''': | ||
<pre> | |||
apt-get install autoconf bison build-essential curl git-core \ | |||
libcurl4-openssl-dev libncurses5-dev libreadline-dev libssl-dev \ | |||
libxml2-dev libxslt1-dev libyaml-dev python-software-properties zlib1g-dev | |||
</pre> | |||
Install the <code>rbenv</code> and <code>ruby-build</code> packages as a '''non-root user'''. '''NOTE: Do this as deployment user in production!''' | |||
<pre> | <pre> | ||
cd | cd | ||
Line 22: | Line 38: | ||
rbenv install 2.1.2 # choose one and install it | rbenv install 2.1.2 # choose one and install it | ||
rbenv global 2.1.2 | rbenv global 2.1.2 | ||
rbenv rehash | |||
ruby -v | ruby -v | ||
gem install bundler -OR- gem install rails | |||
rails new webapp -d mysql | |||
</pre> | </pre> | ||
Line 33: | Line 52: | ||
# install a Ruby version: | # install a Ruby version: | ||
$ rbenv install 2.0.0-p247 | $ rbenv install 2.0.0-p247 | ||
# show installed ruby versions | |||
$ rbenv versions | |||
</pre> | </pre> | ||
Downloads source, compiles, and stores the result in <code>~/.rbenv/versions/</code> | Downloads source, compiles, and stores the result in <code>~/.rbenv/versions/</code> | ||
=== Update the list of available versions === | |||
<pre> | |||
cd ~/.rbenv/plugins/ruby-build | |||
git pull | |||
</pre> | |||
== rbenv rehash == | == rbenv rehash == |
Latest revision as of 22:49, 6 February 2020
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
Upgrade to latest version
cd ~/.rbenv git pull cd plugins/ruby-build git pull
Setup
Install needed packages as root:
apt-get install autoconf bison build-essential curl git-core \ libcurl4-openssl-dev libncurses5-dev libreadline-dev libssl-dev \ libxml2-dev libxslt1-dev libyaml-dev python-software-properties zlib1g-dev
Install the rbenv
and ruby-build
packages as a non-root user. NOTE: Do this as deployment user in production!
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 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 rbenv rehash ruby -v gem install bundler -OR- gem install rails rails new webapp -d mysql
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 # show installed ruby versions $ rbenv versions
Downloads source, compiles, and stores the result in ~/.rbenv/versions/
Update the list of available versions
cd ~/.rbenv/plugins/ruby-build git pull
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