We recently switched from RVM to rbenv for managing Ruby versions.
> “Make each program do one thing well.” - Tenet #2 of The UNIX Philosophy
The UNIX philosophy espouses an approach to software in which small, sharp tools are designed and used to address discrete needs. By this standard, RVM simply does too much. RVM is responsible not only for changing Ruby versions, but for installing rubies and managing gemsets, as well.
Breaking these responsibilities apart and selecting a tool for each job is a good alternative to using RVM. Along with rbenv, we’re using Bundler to manage gems (replacing gemsets) and ruby-build to install rubies.
rbenv rehash command after new Ruby executables are installed (rehashing can be automated with the gem rehash plugin)~/.rbenv/Check out our laptop script to see our process for installing rbenv, or follow the steps below.
If you’re a tmux user, be sure to kill all your tmux sessions before installing rbenv to prevent RVM from polluting your environment.
In your root directory, remove RVM from your system:
rvm implode
Restart your shell to ensure you’re beginning your rbenv installation in a clean environment:
exec $SHELL -l
Next, install rbenv using homebrew:
brew update
brew install rbenv
Configure your bash or zsh profile:
echo 'eval "$(rbenv init -)"' >> ~/.zlogin
source ~/.zlogin
Install ruby-build and rbenv rehash gem using homebrew:
brew install rbenv-gem-rehash
brew install ruby-build
Install your preferred version of Ruby and set it as the global default:
rbenv install 1.9.3-p392
rbenv global 1.9.3-p392
Update to the latest Rubygems version:
gem update --system
Install gems critical to Rails development, e.g.
gem install bundler foreman pg rails thin --no-rdoc --no-ri
You can set project-specific Ruby and gem versions by running the rbenv local command within your project directory:
rbenv local 1.9.3-p385
If you follow the steps above and find you’re having issues with rbenv, check your echo $PATH. Most likely you’re not seeing the appropriate ~/.rbenv dir.
If so, you either haven’t added the init to your zsh profile, or something else is mangling the path.
bundle exec when you run commandsWritten by Laila Winner

Earlier today, OS X Mountain Lion was released for all users in the Mac App Store. As a member of the Mac Developer Program, I decided to tame this wild cat early on, jumping on the beta tester bandwagon since the Developer Preview 4. Here are some of the things you should consider as you make the switch to this shiny new operating system.
After I downloaded the 4GB installer from the Mac App Store, the whole upgrade process took me about 45 minutes on my 15” 2010 Macbook Pro with an SSD drive. It was a simple and straightforward process as the installer takes care of everything.
Once the installer is done, we need to do some additional work to get up to speed once again and be able to compile Ruby (using RVM or rbenv) or install packages using Homebrew. Hold on to your champagne for now.
You can get Xcode from the Mac App Store. You’ll need at least version 4.4 of
Xcode for it to work with OS X Mountain Lion. After the installation, open up
Xcode in your /Applications folder. You’d want to go to Xcode -> Preferences
-> Downloads tab then install the “Command Line Tools.” After you’re done, quit
Xcode and fire up Terminal.
After the upgrade, Apple will set the ownership of your /usr/local folder to
root. You can easily fix this by running this command in Terminal:
sudo chown -R `whoami` /usr/local
Next, you need to update Homebrew:
brew update
If you need to install any Ruby that’s older than 1.9.3, such as 1.9.2, 1.8.7
or REE, you’ll need to install GCC 4.2. Apple does not ship the Command Line
Tools with gcc-4.2 compiler anymore (you can check by running which
gcc-4.2), so you need to install it via Homebrew. By default, Homebrew doesn’t
include any formula that ships with the OS in the main repository, so you’ll
have to enable homebrew-dupes repository by using brew tap
brew tap homebrew/dupes
brew install apple-gcc42
Voila! Now you can compile any library that requires non-LLVM GCC.
Note: If you were using a binary package from MySQL website to install your MySQL server, you will need to change the ownership of your MySQL data directory back by issue this command:
sudo chown -R mysql:mysql `brew --prefix`/mysql
Now, if you’re still using some application that depend on X11, such as Divvy or gitk, you’ll need to install X11 as well. Apple has already removed X11 support from their operating system, but you can still get the X11 package from XQuartz. I’ve been using their 2.7.2 release, and it’s working fine for me.
Before performing any major upgrade, always make sure that you have the latest backup of your Mac. If you already have Time Machine set up, all you need to do is intiate another manual backup. It’s also a good idea to verify your backup afterward to make sure that it’s working.
If you have been leading a carefree life and did not bother setting up Time Machine, or would like to make sure that you can come back to Lion if something is broken, I would suggest using Carbon Copy Cloner to clone your internal hard drive to an external one. (Once the upgrade is done, I would still recommend you set up Time Machine.)
Finally, your developer machine has been upgraded to OS X Mountain Lion. I hope you’ll enjoy the new features as much I do. Happy coding!
When installing Ruby 1.8.7 with rbenv, there were compilation issues due to an issue with Tk. After digging through the output log, it turns out it was looking for an Xlib header and failing. This can be resolved by exporting an additional include path to GCC:
export CPPFLAGS=-I/opt/X11/include
If you’re not using bundler’s binstubs with RVM integration yet, you should give it a try! This means you don’t have to type “bundle exec” ever again.
Setup:
chmod +x $rvm_path/hooks/after_cd_bundlerbundle install -—binstubsWith rvm integration enabled, the “bin” directory is added to your path each time you cd into a project directory with binstubs. That means you can just run “rake”. If you aren’t ignoring the “bin” directory in your project, you should do so:
# .gitignore
bin/
It’s been two and a half years since my last laptop. It’s neat to look back and see how much has improved since then for setting up a Ruby development environment.
Of particular note, Homebrew, RVM, and Bundler did not exist back then.
Here’s how I set up an OS X 10.7 (Lion) thoughtbot laptop in 2011.
I need GCC to help install everything else so I downloaded GCC for Lion.
We used to have to install XCode to get GCC when OS X wasn’t for developers, which was a 3-4GB download and took 10GB+ of space. Buzzkill.
However, Kenneth Reitz, one of the Readability guys, fixed this with his OS X GCC installer, which is a comparatively svelte 272MB download.
Later on, when we’re installing things using Homebrew, we’ll see warnings like:
Xcode is not installed! Builds may fail!
But, the builds will build fine.
While that’s installing, we’ll customize our environment a little.
I need a public key to get access to private Github repositories.
ssh-keygen -t rsa
I’m kept hitting “enter” until it was done. Alternatively, I could have brought my old SSH key over but I’m not into falconry.
We have a standard set of configurations for vim, irb, git, zsh, and more.
I cloned the repo:
git clone git://github.com/thoughtbot/dotfiles.git
I ran the installer:
./install.sh
This sets up the appropriate symlinks (~/.vimrc, ~/.irbrc, etc.). I’ll stay up-to-date and contribute using the fork-track-update flow described in the README.
Our dotfiles assume zsh so I switched from the bash default to zsh:
chsh -s /bin/zsh
We’re pretty much all vim users here so it’s nice having super-quick home-row access to the Control key… and who uses Caps Lock, anyway?
System Preferences > Keyboard > Modifier Keys
Already installed by default, but I set the global config:
git config --global user.name "Your Name"
git config --global user.email you@example.com
I’m using Heroku for all my apps right now. However, thoughtbot’s clients and even our own apps like Trajectory are not owned by my Heroku account. So, it comes in handy to be able to switch to a different account on a project basis.
heroku plugins:install git://github.com/ddollar/heroku-accounts.git
heroku accounts:add dan --auto
heroku accounts:add thoughtbot --auto
heroku accounts:add client --auto
heroku accounts:default dan
Once GCC is downloaded and installed, I’m ready for the heavy-duty installation using our laptop script.
bash < <(curl -s https://raw.github.com/thoughtbot/laptop/master/mac)
This installs:
It took about 15 minutes for everything to install.
While it’s running, it copies your SSH key to the clipboard and opens your Github SSH page. Paste your SSH key so your Github account is authenticated to your machine.
We wrote a laptop script because we help hundreds of people a year get a Ruby development environment set up at workshops and Boston Ruby hackfests. One time we set up 30 business school students’ laptops in 3 hours.
If you read our source, you’ll see it it’s very simple but more invasive than, say, the excellent Cinderella by Corey Donohoe, which uses Chef to keep your machine tidy. We’re assuming the person definitely wants a “thoughtbot laptop”.
It’s pretty easy to write a wrapper that installs Homebrew, RVM, and your favorite databases and gems so consider forking our project and writing your own script, just like you might write your own Rails template script like Suspenders.