Version 2 (modified by mojca (Mojca Miklavec), 6 years ago) (diff)

workaround for nokogiri

<- 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 rb22-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.2.3
rbenv global 2.2.3
ruby -v

Installing Rails

gem install rails -v 4.2.4

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 (a bug is the installer). A workaround might be the following:

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

but the gem might stop working when you upgrade libxml2 from MacPorts.

Setting up the Database


(see also MySQL HOWTO)

<- Back to the HOWTO section