Posted over 4 years ago. Visible to the public.

rbenv: A basic introduction

Why

We have projects that have been developed using many different versions of Ruby. Since we do not want to constantly update every old project, we need to have many Ruby versions installed on our development machines.

Rbenv Archive does that for us.

How it works

Rbenv installs ruby version and ruby gems to ~/.rbenv/versions/VERSION_NUMBER/.... This way many different Rubies can be installed at once.

When you run ruby or gem or bundler or any other Ruby binary

  • rbenv looks for a file .ruby-version in your directory (or any parent directory)
  • and sets your PATH to the correct Ruby on the fly

Installation

Check our card on installing rbenv.

Basic workflow

Choose your version

To use a specific Ruby version for your project, add a file .ruby-version that simply contains the version you want:

Copy
2.3.1

If you need to switch the version outside of a project for your current shell, you can also say

Copy
rbenv shell 2.3.1

Note that this causes your shell to ignore the .ruby-version until you close it.

Show current version

To see the currently selected version (hopefully "2.3.1"), run

Copy
rbenv version

It will warn you if the version is not currently installed.

Install a missing version

Copy
rbenv install 2.3.1

You can skip the version number to install the currently selected one.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Tobias Kraze
Last edit:
over 4 years ago
by Tobias Kraze
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more