Setting up your environment can be difficult when you’re first starting with Ruby. We want to get the following installed:
- Ruby 1.9.3
- A text editor
The setup instructions are broken down by the following platforms: Mac; Linux; and Windows.
Mac OS is the most popular platform for Ruby and Rails developers. To have a properly setup dev machine you want the following:
OS X Mountain Lion
- Install free XCode app from the Apple store. This app allows for the installation of the Comand Line Tools which are required for the successful installation of all ruby related content on Mac OS.
- Once XCode app is installed, go to Preferences > Downloads > Install Comand Line Tools.
Other Mac OS versions
Command Line Tools for XCode
- Create or Register an Apple ID.
Register with the same Apple ID you use for other Apple services, such as iTunes, iCloud, and the Apple Online Store.
- Login to the Apple Developer Portal.
- Search for "Command Line Tools (OS X Lion) for Xcode" or "Command Line Tools (OS X Mountain Lion) for Xcode".
- Download and install the package.
Homebrew is a package management system that makes it super easy to install hundreds of open source projects and compile them from source for maximum performance on your machine.
Git is the version control system of choice in the Ruby community.
RVM allows you to install and maintain multiple versions of Ruby. More information about Ruby Version Mananger (RVM) can be found at http://rvm.io
If Mac OS isn’t a possibility, then your next best bet is Linux. Among distributions, Ubuntu has the best support for Ruby and Rails development. You’ll need:
- Git (
sudo apt-get install git-core)
- RVM (http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/)
You want to avoid managing Ruby, RubyGems, etc. through your package management solution (
apt). The packages available usually lag months behind the real source code repositories, and it is going to cause you massive headaches.
Instead, setup RVM and handle everything through there (as we’ll discuss in the next section).
If you’re going to be doing Rails work, then you should also install Node.js. You can get it from your distribution’s package manager. If you’re using Ubuntu, like above:
sudo apt-get install node
Getting started on the Windows platform is actually very easy. Engine Yard (http://engineyard.com) has put together the RailsInstaller (http://railsinstaller.org/), a single package installer with all the tools you need to get working. Make sure that, during the setup, you check the box to configure your environment variables. You can stop after step 2, once you’ve entered your email and name in the DOS prompt.
Beyond initial setup, though, there is going to be pain. As you add in more Gems and other dependencies you’ll find that many of them utilize native extensions, code written in C for better performance. Unless the authors have put energy into being cross-platform, you’ll run into issues.