<- Back to the HOWTO section

About RubyOnRails


Please note:

MacPorts packages some outdated versions of Rails like

  • rb-rails @2.3.5
  • rb19-rails @3.0.5

In ideal world the packaging of these modules would be better and more up-to-date, so that installing Ruby on Rails would be as straightforward as

port install rb23-rails4.2

but until then you need to use other tools with a wider base of maintainers.


These instructions are based on, but skipping the part that explains how to install another package manager.

Installing rbenv and ruby-build

You first need to install the necessary tools:

port install rbenv ruby-build

Adding rbenv to ~/.bash_profile (optional)

If you want to enable rbenv by default, you can add eval "$(rbenv init -)" to ~/.bash_profile:

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

Please note that this will hide the ruby as installed by MacPorts using port select ruby .... If you want to switch back to that version of ruby, you should comment out that line in ~/.bash_profile again.

Installing Ruby

rbenv install 2.3.0
rbenv global 2.3.0
ruby -v

Installing Rails

gem install rails -v 4.2.6

To make sure that rbenv knows about the new version of rails you additionally need:

rbenv rehash


There might be some problems related to installation of nokogiri 1.6.7 (a bug in the installer). As a workaround you can use:



gem install nokogiri -- --use-system-libraries --with-xml=/opt/local/

before installing rails which will link against the libxml2 library from MacPorts (but note that it might stop working if you happen to upgrade to an abi-incompatible version of that library or if you uninstall it). The problem was apparently fixed in nokogiri version 1.6.8.

Setting up the Database


(see also MySQL HOWTO)

<- Back to the HOWTO section

Last modified 8 years ago Last modified on Apr 6, 2016, 3:25:05 AM