How To Install Ruby on Rails on FreeBSD 10.1 using RVM

Ruby on RailsFreeBSD


Ruby on Rails, or RoR for short, is a very popular full-stack web application development framework written in Ruby. It allows you to rapidly develop web applications that conform to the MVC (model-view-controller) pattern.

This tutorial will cover how to set up a Ruby on Rails development environment using RVM on your FreeBSD 10.1 server.


Before you begin, all you need is:

  • A FreeBSD 10.1 Droplet.

  • A user with root privileges. (The default freebsd user is fine.)

Step 1 — Setting bash as the Default Shell

This tutorial will use the Ruby Version Manager, or RVM for short, to install Ruby. Because RVM works best with bash 3.2.25 or higher, in this step, we will install bash and set it as the default shell.

Before we begin, log into your FreeBSD 10.1 server.

  • ssh freebsd@your_server_ip

Next, install the latest version of bash using pkg.

  • sudo pkg install bash

We’ll need to add a line to /etc/fstab for bash to work. Open the file using ee or your favorite text editor.

  • sudo ee /etc/fstab

Add the line fdesc /dev/fd fdescfs rw 0 0 to the end of the file as shown below.

# Custom /etc/fstab for FreeBSD VM images
/dev/gpt/rootfs /       ufs     rw      2       2
/dev/gpt/swapfs none    swap    sw      0       0
fdesc    /dev/fd     fdescfs     rw  0   0

Save and exit the file, then mount the new entry.

  • sudo mount -a

Now that bash is installed, set it as your default shell using the chsh command.

  • sudo chsh -s bash

To start using bash, log out and log back in to your server. If you don’t want to log out, you can start a bash session manually by typing in:

  • bash

Step 2 — Installing RVM

In this step, we will install RVM.

To download the RVM installer, you first need to install curl.

  • sudo pkg install curl

Move to the /tmp directory.

  • cd /tmp

Download the RVM installer script from https://get.rvm.io.

  • curl -sSL https://get.rvm.io -o installer.sh

Finally, use the script to install the latest stable release of RVM.

  • bash installer.sh stable

Because RVM makes a few changes in your shell’s startup configuration, the recommended way to activate those changes is by logging out of your current session and logging back in. Alternatively, you can apply the changes to your current session manually by running:

  • . ~/.rvm/scripts/rvm

Step 3 — Installing Ruby

You can now use RVM to install any version of Ruby. Because 2.2.2 is the latest stable version available as of June 2015, we’ll install this version.

  • rvm install 2.2.2

This will take a moment. Once the installation completes, list the rubies available on your system.

  • rvm list

If your installation was successful, you will see:

rvm list output
rvm rubies

=* ruby-2.2.2 [ i386 ]

# => - current
# =* - current && default
#  * - default

To confirm that Ruby 2.2.2 is present in your $PATH, type in:

  • ruby -v

You should see a message that looks like this:

ruby -v output
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-freebsd10.1]

Step 4 — Installing Ruby on Rails

In this step, we will install Ruby on Rails.

Because Ruby on Rails is a gem, it can be easily installed using RubyGems (Ruby’s package management framework) using gem install rails. However, this installation will take a while to complete because it includes lots of other gems (some of which need to be compiled) and their documentation files. You can speed up this command considerably by adding the --no-rdoc --no-ri flags, which will skip the documentation installation.

Install Ruby on Rails, optionally without documentation.

  • gem install rails --no-rdoc --no-ri

For the Rails Assets Pipeline to work, a Javascript runtime should be present on your server. The easiest way to get one is by installing Node.js using pkg.

  • sudo pkg install node-devel

Step 5 — Creating a Test Project

Now that the Rails installation is complete, let’s test it by creating an empty project inside the /tmp directory.

If you’re not still in the /tmp directory, change to it.

  • cd /tmp

Use the rails command to create a new project called test-project (or whatever you like).

  • rails new test-project

Enter the project directory.

  • cd test-project/

And finally, try starting the Rails console.

  • rails c

If your Rails installation was successful, you should see the following prompt:

rails c prompt
Loading development environment (Rails 4.2.1)
2.2.2 :001 >

You can exit the prompt by entering exit.

  • exit


In this tutorial, you learned how to set up Ruby on Rails on your FreeBSD 10.1 server. You can now use your FreeBSD server as a development environment for your Rails projects!

While doing so, you also learned how to install Ruby using RVM. If you want to learn more about RMV, check out this tutorial on how to use RVM to manage your Ruby environments.

Creative Commons License