Skip to contentSkip to navigationSkip to topbar
Rate this Page:

How to Set up a Ruby Local Development Environment


To complete the Twilio Ruby quickstarts, you'll need to have the following tools installed:

We'll cover the installation process for all of these dependencies.


Install Ruby

install-ruby page anchor

If you are on a Mac or a Linux machine, you probably already have Ruby installed. You can check by typing this at the command line:


_10
ruby -v
_10
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]

If you get any output back other than ruby: command not found, you've got Ruby installed. If you don't, follow these instructions to install Ruby for Mac or Linux(link takes you to an external page).

If you're using Windows, download the RubyInstaller(link takes you to an external page) package, which contains a complete Ruby environment.

Install RubyGems

install-rubygems page anchor

Third-party dependencies in Ruby are managed with RubyGems(link takes you to an external page), a command line tool that makes it very easy to add new libraries and include them in your Ruby projects. You can check if you have RubyGems installed already by running this at the command line:


_10
gem --version
_10
1.8.24

If you get gem: command not found, you can download RubyGems from their downloads page(link takes you to an external page).

RubyGems for Windows will be installed by RubyInstaller.


Install Sinatra and twilio-ruby

install-sinatra-and-twilio-ruby page anchor

Once you have RubyGems installed, installing Sinatra and twilio-ruby is a snap. Just type this at the command line:


_10
gem install sinatra twilio-ruby

RubyGems will take care of the rest of the work.


Test the installation out

test-the-installation-out page anchor

Let's try our installed tools out with a short test file. Create a new file called test.rb and add the following code:


_10
require 'rubygems'
_10
require 'twilio-ruby'
_10
require 'sinatra'
_10
_10
get '/' do
_10
'Hello World! Currently running version ' + Twilio::VERSION + \
_10
' of the twilio-ruby library.'
_10
end

Now start up a local web server by running your test.rb file at the command line:


_10
ruby test.rb

You should see output like this:


_10
Sinatra/1.3.2 has taken the stage on 4567 for development with backup from Thin
_10
>> Thin web server (v1.4.1 codename Chrome)
_10
>> Maximum connections set to 1024
_10
>> Listening on 0.0.0.0:4567, CTRL+C to stop

Now load http://localhost:4567(link takes you to an external page) in a browser. You should see a "Hello World" message, with the version of the twilio-ruby library posted too.

If you received an error along the way, contact our support team with a description of what you were trying to do, what you expected to see, and what happened. They'll be glad to help you figure out what's going on.


Now that you've got your local environment set up, you're ready to dive into the Quickstarts. Have fun!


Rate this Page: