Ecrubylogo

Getting Started with Ruby

Last updated 2011-12-10

Ruby is one of the most powerful languages available today, and it's also one of the easiest to learn. This page contains everything you need to know to get started working with Ruby today.

Giving Ruby a Spin

You don't need to install anything on your computer if you just want to get your feet wet. Visit Try Ruby (In Your Browser!) and follow along with the interactive tutorial to see how easy Ruby's syntax is.

Quick links

Getting Ruby set up on your machine

Ruby is relatively easy to install on nearly every platform. However, we recommend installing Ruby 1.9.2 at the moment.

Windows

Windows users can grab the RubyInstaller For Windows which will install Ruby and the Rubygems package manager.

Once installed, open a Command Prompt and type

gem update --system

This updates Rubygems to the latest version if necessary.

Next, follow these instructions to install additional components for Ruby libraries that need to be compiled.

Need a Ruby editor?

We recommend RedCar which you can install as a RubyGem.

gem install redcar
redcar install

And that's all you need.

Mac OS X

Both Leopard and Snow Leopard come with Ruby already installed, You'll be happier if you use RVM, the Ruby Version Manager. To do this, you'll need the GCC compilers. Install XCode from your OSX DVD, or grab prebuilt compilers from here

Next, install Git using the Git OSX Installer

Finally, open a Terminal and type these commands:

bash < <( curl -s https://rvm.beginrescueend.com/install/rvm )
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" ' >> ~/.bash_profile

Now close and restart Terminal. Then type

rvm install 1.9.2
rvm --default 1.9.2

Need a Ruby editor?

We recommend Textmate (30 day trial, OS X DMG)

Linux (Ubuntu)

Use rvm the Ruby Version Manager, to get everything running. Type these commands from a new Terminal:

sudo apt-get install build-essential git-core curl

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc 

sudo apt-get install build-essential bison openssl libreadline6 \
libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev \
libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \
libxslt-dev autoconf

Now close and restart your Terminal, and type:

rvm install 1.9.2

rvm --default use 1.9.2

Next, install RubyGems to manage packages

mkdir src
cd src
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar xzvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

Need a Ruby editor?

We recommend Vim. A Rails plugin is available.

Rails

To install Rails on Windows, simply download the RailsInstaller for Windows to get Ruby, Rails, and everything else installed.

To install on Linux or Mac OSX, open a terminal and type:

gem install rails 

Build something

Now that you have Ruby installed, try building something fun.