Installing Ruby can be difficult sometimes. With the number of different operating system distributions, number of versions, and possible local configurations, it is hard to make a one-stop install that fits every user's need.

The primary resource for installing Ruby remains the download page on the ruby-lang site itself.

If you can, you should first try to install Ruby using tools such as rvm?, rbenv?, ruby-build?, and so on.

These represent the minimal set of steps to install Ruby on a Linux system from the source. To install Ruby from on a Mac, use HomeBrew?. To install Ruby on Windows, please see RubyInstaller.

Install your favourite distribution

These instructions work for any Debian-based linux system, as well as some others.

The Debian system installer, apt?, is assumed here. Other linux distributions have different installers, and potentially other package names.

Log in as root

$ sudo -i
Password: # enter your user's password

Install Packages Ruby Needs to Build from Source

$ apt-get install <package> # see list below

Ruby needs these to build correctly.

  • build-essential
  • git-core
  • curl
  • bison
  • openssl
  • libreadline6
  • libreadline6-dev
  • zlib1g
  • zlib1g-dev
  • libssl-dev
  • libyaml-dev
  • libxml2-dev
  • libxslt-dev
  • autoconf
  • libc6-dev
  • ncurses-dev
  • libcurl4-openssl-dev
  • libopenssl-ruby
  • apache2-prefork-dev
  • libapr1-dev
  • libaprutil1-dev
  • libx11-dev
  • libffi-dev
  • tcl-dev
  • tk-dev

These will pull in other packages as needed.

  1. $ apt-get install build-essential git-core curl bison openssl \
  2. libreadline6  libreadline6-dev zlib1g zlib1g-dev libssl-dev \
  3. libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev \
  4. libcurl4-openssl-dev libopenssl-ruby apache2-prefork-dev libapr1-dev \
  5. libaprutil1-dev libx11-dev libffi-dev tcl-dev tk-dev

Acquire the Ruby Source

Download the latest version of Ruby here: under the Compiling Ruby Source code section.

cd /usr/src
tar zxvf ruby-2.1.0.tar.gz
cd ruby-2.1.0

Do the needful

This is the point where you will actually configure, build, and install ruby onto your system. Deciding where to put the new version is something you have to consider.

Installing into /usr directory will replace the existing system ruby. This isn't a bad idea in all cases, but some packages and utilities may rely on features in the old version of ruby. Still, I haven't encountered any problems in do this on a modern running debian-based system.

Installing into /usr/local is a popular option, but you need to ensure that you have your environment set up to know which ruby to run. When logged in, it is rather simple to keep the /usr/local directory before the /usr directory in your PATH environment variable, which is all that should really be necessary. However, in other environments, such as crontab and other system settings, you might need to do a little more to ensure the PATH is set correctly.

./configure --prefix=/usr # default setups
make # compiles the source
make install # installs the programs in /usr/bin, etc

Test the install

which ruby; ruby --version
which irb; irb --version
which gem; gem --version
which rake; rake --version

Install some gems

gem install bundler
gem install rails

bundler is probably the most important gem to install. It is used to manage gems for developing programs, libraries, ruby packages, and applications. Install it, and be happy.

Rails is the premier web application framework based on Ruby and is the reason so many people learn Ruby. It's not the only one, so you don't have to install it, but it's really a good test of a new installation of ruby.

Logout from root, login as user

Of note, since you've compiled and installed ruby as the system ruby, you will need to continue installing gems as the superuser, unless you set the environment variable GEM_PATH in your user's .profile to something you can write to. This is the best way to do development, with your own local per-user set of gems. When you deploy your ruby projects, you'll be able to decide at that point where and how to install necessary gems.

Create a new gem

  1. $ mkdir -p ~/Projects/ruby_projects
  2. $ cd ~/Projects/ruby_projects
  3. $ bundle gem my_test_gem

Create a test rails app

  1. $ mkdir -p ~/Websites/rails
  2. $ cd ~/Websites/rails
  3. $ rails new my_test_rails

Summary: A step-by-step recording of building a Ruby dev system from source Parent:(Technology.)Ruby IncludeMe?:Ruby Categories:Articles, HowTos Tags: ruby, howtos

Children of this page:


Post a comment:

Items marked * are required.

Name: *
Email: *

Your Message *

Enter value 838 * : <- Have you entered the code number?


A500 AJAX Actionmailer Actionscript Activerecord Ai Android Apache Api App config Apple Applicaitons Application Art Artificial intelligence Aruba Authentication Backbone Backbone.js Backups Beautiful code Best practices Bibtex Blogging Bokeh Book review Bookmarks Brew Business CI CSS Calendars Calibre Capture Cgi Character sets Checkboxes Checklists Chrome Classes Cleaning up repositories Cli Click fraud Cms Code Code craftsmanship Cold fusion Coldfusion Command line Comparable Comparisons Compiz Compression Computers Configuration Continuous integration Conversion Cron Crontab Cross-platform Css Css3 Cucumber Curl DBMS DRM Data relationships Data serialization Database Database design Databases Date parsing Dbms Debian Debugging Defaults Deploying Deployment Design Development Devops Dia Distro Doctorow Documentation Drop cap Drupal Duplicate values Ebook Eclipse Editing Editors Eggdrop Emacs Emacs modes Emerge Empty subdirectories Encoding Engineering Enumerable Enumerator Environment Environments Etech talk Examples Extract urls FOSS Faq Feral robots Ffmpeg File uploads Filters Finder Flash Flip flop Float Float containment Fluid design Forms Framework Frameworks Freebsd Gem Gems Gentoo Getting started Git Gmail Google Grant H2xs Hacking Hard landscape Hardware Hash Hashes Headless Hidden files Homebrew Hosting How to How-to Howto Howtos Html Http header Http server Http-response Humour Idioms Image slider Imap Includes Installation Interactive Ios Ip address Irc Irssi Issues Java JavaScript Javascript Jekyll Joomla Jquery Kindle Languages Latex Layout Life Link shortener Links Linux Lipsum Lisp Logging Logos Lorem ipsum Lwp M4a Mac Magic constants Maintenance Management Markup Maven Mavericks Metaprogramming Mime types Miniapplications Mocha.js Modularity Modules Morals Mountain lion Mounting Mp3 Mtime Mysql Navigation Nesting Networking Networks Nfs Nginx Node Node.js Notes Oneliners Oo design Oo development Oop Open-source Operating systems Optimization Options Os/x Osx PHP Package manager Packages Palm Palmos Parameters Parsing Passwords Pcre People Perl Permissions Photoshop Php Pipeline Pmwiki Pmwikifarms Polymorphism Postgres Postgresql Premature end of script headers Presentation Press and hold feature Problems Programming Programming languages Programming techniques Projects Psych Python Quality assurance Rails Rake Rakefile Range Rdoc Reading files Recipes Refactoring Regex Remind Reminders Remote logins Remote shell Repositories Resource Resources Responsive design Reuse Reviews Ri Rich media Robotics Robots Root Rsync Ruby Ruby object model Rvm SCM Saved page Saved pages Screenshots Scripting Scripts Secure shell Security Selenium Selinux Server Server administration Services Setup Sharing connections Simple Simple tools Sinatra Single test Skins Slurp Smarty Snippets Social Software Solutions Source control Sql Ssh Ssi Stackoverflow Static site Stderr String Strings Structure Style Styles Suexec Switch statement Syntax Sysadmin Table creation Tags: testing Task management Tcl Technology Tedtalk Templating Testem Testing Text editors Themes Time Titlecase Tivo Tk Tools Travis Tutorial Typesetting UI Design UX UX Design UX Testing Ubuntu Unicorn Unit testing Upstart User Interfaces Version control Weather Web Web 2.0 Web application Web applications Web design Web development Web development popups Web fonts Web programming Web services Web sites Webapps Webdings Wiki Wikifarms Windows Witem Word processing Wordpress Workspace Www XHTML Xbel Xml Yahoo Yaml _why