Showing posts with label ruby 1.9.3-p125 rails rvm rbenv linux install source code bundler. Show all posts
Showing posts with label ruby 1.9.3-p125 rails rvm rbenv linux install source code bundler. Show all posts

Friday, April 6, 2012

Installing and compiling Ruby from the source code

There are several different ways to install Ruby with the most popular being RVMand rbenv. Both have their advantages and disadvantages, but rbenv is a newer and more "lightweight" Ruby installer. I'll let you Google the differences between RVM and rbenv if you are more curious. I decided to install Ruby by downloading the source code and then compiling it myself. I'll be installing Ruby 1.9.3-p125 (the latest version as of writing this) on Debian Linux 6 (Squeeze).

1. First we need to install some development tools and libraries that Ruby needs to compile. Run the following commands from your terminal:
   apt-get install build-essential vim git-core curl

   apt-get install bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev

   apt-get install libcurl4-openssl-dev libopenssl-ruby apache2-prefork-dev libapr1-dev libaprutil1-dev

   apt-get install libx11-dev libffi-dev tcl-dev tk-dev
Note you may need to run these commands as root or use sudo.

2. Download the latest version of Ruby here: http://www.ruby-lang.org/en/downloads/ under the Compiling Ruby — Source code section.

3. Extract the tar.gz file e.g. ruby-1.9.3-p125.tar.gz by typing:
tar -xvf ruby-1.9.3-p125.tar.gz
4. Open the README and follow the instructions on how to compile and install Ruby.
./configure
make
make test
make install
The install process will probably take a while, but once it's done, we can test to see if ruby installed successfully by typing "ruby -v" in the terminal. You should see something like, "ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]" if ruby installed correctly. Next we can install the Bundler and Rails gems to make sure Ruby is working correctly.
gem install bundler
gem install rails
Lastly, create a new Rails project to test to make sure everything works!