Rails on El Capitan

DZone 's Guide to

Rails on El Capitan

Great! You've upgraded to OS X El Capitan. Unfortunately, Rails might not work as promised. Here's a guide to using Rails on El Capitan, with an awesome homebrew guide.

· Integration Zone ·
Free Resource

After upgrading to El Capitan you might find there as some failure in the Rails setup you run with. For example, stuff like Homebrew might not work properly, which means your Postgresql installation gets messed up. RVM might also get a bit weird. So, here’s what I’ve found so far, and what you can do to fix it.


You’ve probably already had an update in for Xcode. If you haven’t, go and get it. The command line tools upgrade will be needed. The ironic thing is: after the Xcode upgrade, you will start to see problems elsewhere with RVM and the like. Still upgrade Xcode though, it’ll be sorted in the end.

Don’t forget to open Xcode and accept the licence agreement too – that’ll mess you up later on otherwise.



The reason for that stark warning is: you are most likely going to have to uninstall Homebrew and that means your datastore is likely to disappear too.

I tried various fixes to stop Homebrew reporting errors when trying to update with:

brew update

But then a call to:

brew doctor

Revealed that there was something weird going on with permissions. A little bit of Googling seemed to imply that Homebrew wasn’t ready for El Capitan yet.

I then visited the Github repo and could see commits referencing El Capitan so I figured a complete removal was in order, so I could reinstall and fix the issues.

There is a handy script for removal:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)";

That’ll nuke it, along with everything you had installed via Homebrew of course. But it only takes about 30 minutes to get everything set back up again.

Next, we’ll reinstall:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

That’s Homebrew sorted, but before we go any further, we’ll sort out RVM.


I think what happened was: I managed to get in a mess with some gem dependencies with a couple of legacy Rails apps I maintain. So RVM got messed up for that reason not because of the upgrade to El Capitan.

I ended up removing it completely so I could start again:

>rvm implode

Then you can remove all traces with:

rm -rf .rvm
rm -rf .rvmrc


Now that I had a clean system, I decided to give rbenv a try. I’ve never used it so it seemed like a good opportunity to try it out. You can install in via Homebrew:

brew install rbenv ruby-build

Next, we want rbenv to be available each time we fire up the Terminal:

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

Finally, we can install Ruby:

rbenv install 2.2.3
rbenv global 2.2.3

And now you can check your Ruby version:

ruby -v


You should now be able to do:

gem install rails

It might bomb out spectacularly, with an error like this:

The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

You can run:

xcode-select --install

To download the command line tools for Xcode. Once they’ve installed (only takes a couple of minutes) try it again. Rails should install successfully this time.

You need to tell rbenv about it though with:

rbenv rehash

And a version check:

rails -v

Should confirm Rails is good to go.


If you removed Homebrew you are going to need to reinstall Postgresql:

brew install postgresql

Then you can make sure it gets started automatically for you:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

This might be enough to have your server up and running. It might fail to start, complaining that directories are missing. Create the directories it claims are missing by moving into the Postgresql directory:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

And then running (for example)mkdir pg_tblspc pg_twophase pg_stat_tmp for all the directories reported missing. Once you’ve done that, your server will start normally.


Now you have Ruby/Rails up and running on your El Capitan installation. If I spot anything else, I’ll update this post.

homebrew, macintosh, rails, ruby

Published at DZone with permission of Andy Hawthorne , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}