Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
We're going to use a program called `rbenv` (short for "RuBy ENVironment") to install and manage our Ruby interpreter on this system. Let's install `rbenv` now.
Run these commands while logged in as the deployment user on your server:
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv (No need for sudo)
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ ~/.rbenv/bin/rbenv init
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
Then log out of your server and back in to load the changes to your $PATH
environment variable.
You can confirm the installation was successful by running rbenv
:
$ rbenv
In case we wind up needing multiple
Ruby versions on this server,
0:00
we're going to use a software
package called rbemv.
0:03
That stands for Ruby environment.
0:07
Rbemv will download and
install Ruby versions for us and
0:11
let us switch between them as needed.
0:14
Note that it shouldn't be confused with
RVM standing for Ruby Version Manager.
0:17
RVM is a bit more complex than rbenv,
and while it's appropriate for
0:22
a development environment.
0:26
It's probably better to
use rbenv in production.
0:27
So let's click on RVM's GitHub site here.
0:33
And then go down to
the installation section.
0:38
And you'll see the command for installing
it here, basically you just git clone
0:41
the repository into your home
directory on your server.
0:46
So we're gonna copy that command and
then go back to our terminal and
0:49
paste it there.
0:52
Next, we need to add rbenv to the list
of paths that Linux searches when it's
0:58
looking for executables.
1:02
So I'm gonna copy the second command here,
and again paste it into my terminal.
1:04
And what this does is it'll just
cause your system to search the rbenv
1:10
directory for executables before it
searches the rest of the directories.
1:15
Next, the install instructions
advise us to run this command,
1:23
to get instructions on how to set
up the rest of our environments.
1:27
We'll copy this,
piece it into the terminal.
1:30
And it says to add this line here to
our bash profile configuration file.
1:34
So I'm going to fire up the nano editor.
1:41
And edit the bash profile file.
1:46
Note that that starts with a dot
here in our home directory.
1:50
And I'm going to paste that
line here on a new line.
1:55
As usual I'll hit Ctrl+O to write
out the file and Ctrl+X to exit.
2:02
Now, to load in these
configuration changes,
2:07
I'm gonna need to restart the shell.
2:09
So I'm going to exit out of the system and
log in again.
2:11
We can confirm the installation was
successful by running the rbenv command.
2:18
The last recommendation here in
the rbenv install instructions is,
2:24
to install the ruby-build plugin.
2:27
Rbenv has plugins which provide
various functionality, and
2:31
the ruby-build plugin allows you to
install new Ruby versions automatically.
2:34
The command you need to install it is
right here at the top of the ruby-build
2:39
page.
2:42
So we're gonna copy that.
2:43
And switch to our terminal and
paste it there.
2:46
Just like before,
2:54
it'll do a git clone into your home
directory into the rbenv plugins folder.
2:55
And now let's try running it.
3:01
We do that with the rbenv command and
we'll use the install sub command.
3:02
We're gonna install a specific
version of Ruby with the -v flag.
3:08
We're gonna install version 2.3.0.
3:14
And they'll download and
install that version for us automatically.
3:18
Again, this might take a little bit.
3:22
When it returns to the system prompt,
your new Ruby version will be installed.
3:26
Now we're going to wanna set it
up to use this new Ruby version
3:31
in every new shell that you open.
3:33
We can do that by running the rbenv
command, the global sub command.
3:35
And we'll use the new version
that we just installed.
3:42
Hit enter to run that.
3:46
And then we can verify our new Ruby
version by typing the ruby command
3:47
along with the -v flag
to check the version.
3:52
And there it is, Ruby version 2.3.0.
3:55
You need to sign up for Treehouse in order to download course files.
Sign up