<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>crunchlife: Installing Ruby 1.8 and 1.9 on Ubuntu from Source</title>
    <link>http://crunchlife.com/articles/2008/09/14/installing-ruby-1-8-and-1-9-on-ubuntu-from-source</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Installing Ruby 1.8 and 1.9 on Ubuntu from Source</title>
      <description>&lt;p&gt;&lt;img src="/files/ruby.png" class="right"&gt;I&amp;#8217;ve begun testing &lt;a href="http://crunchlife.com/articles/2008/07/03/ruby-fractal-library" target="_blank"&gt;my fractal library&lt;/a&gt; with the latest source code from the Ruby 1.9 trunk. Since 1.9 is a development release and I still need 1.8 for my Rails applications, I&amp;#8217;ve checked out both versions and configured them to run side-by-side on Ubuntu, Hardy Heron.&lt;/p&gt;

&lt;p&gt;Before you begin, make sure you have the autoconf, build-essential, and subversion packages installed.&lt;/p&gt;

&lt;p&gt;It may also be a good idea to include the Ruby1.8 and Ruby1.9 build dependencies from Ubuntu&amp;#8217;s package repository. This could prevent some headaches later on.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ sudo apt-get build-dep ruby1.8 ruby1.9&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Create a directory for the Ruby source code.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ mkdir /home/ryan/source
$ cd /home/ryan/source&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Check out the code from the 1.8 branch. Since this branch includes patches, you can always update your source and recompile when new patches are released.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 ruby1.8&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Next, create a configuration, configure, and compile.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ cd ruby1.8
$ autoconf
$ ./configure --prefix=/opt/ruby1.8 --program-suffix=1.8
$ sudo make
$ sudo make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;One of the best parts of Ruby is &lt;a href="http://www.rubygems.org/" target="_blank"&gt;Rubygems&lt;/a&gt;! Download and install it. &lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
$ tar -xvzf rubygems-1.2.0.tgz
$ cd rubygems-1.2.0
$ sudo ruby1.8 setup.rb&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Finally, link your new binaries to the /usr/local/bin directory.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ sudo ln -s /opt/ruby1.8/bin/* /usr/local/bin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Typing ruby1.8 -v in a new console should yield something similar to the following:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ ruby1.8 -v
ruby 1.8.7 (2008-09-15 revision 19348) [i686-linux]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The current source for Ruby 1.9 requires version 1.8 to compile, but if you&amp;#8217;ve followed my directions up to this point you should be ready to download and compile the latest Ruby 1.9 source code. &lt;/p&gt;

&lt;p&gt;Go back to your source directory and check out the latest code from the 1.9 trunk.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ cd /home/ryan/source
$ svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby1.9
$ cd ruby1.9&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This time use the &amp;#8211;with-baseruby switch when configuring. Set this option to the new Ruby 1.8 binary and then compile.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ autoconf
$ ./configure --with-baseruby=/usr/local/bin/ruby1.8 --prefix=/opt/ruby1.9 --program-suffix=1.9
$ sudo make
$ sudo make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Finish by linking your new Ruby 1.9 binaries to /usr/local/bin.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ sudo ln -s /opt/ruby1.9/bin/* /usr/local/bin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Typing ruby1.9 -v in your console should yield something similar to the following:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ ruby1.9 -v
ruby 1.9.0 (2008-09-15 revision 19351) [i686-linux]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ruby 1.9 includes Rubygems! We&amp;#8217;re done!&lt;/p&gt;

&lt;p&gt;Since the binaries we&amp;#8217;ve created have been suffixed with either 1.8 or 1.9, you must remember to execute them with their proper name ie (gem1.8, gem1.9, ruby1.8, ri1.9).&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve written these instructions from memory so if you have any problems, please post them and I&amp;#8217;ll try to help out as best I can. Please be warned, however, that not all code written for Ruby 1.8 will work in 1.9.&lt;/p&gt;</description>
      <pubDate>Sun, 14 Sep 2008 13:30:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:122f8a10-a010-40fb-9010-b102dc451ac3</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/09/14/installing-ruby-1-8-and-1-9-on-ubuntu-from-source</link>
      <category>Code Snippets</category>
      <category>Ruby</category>
      <category>Ubuntu</category>
    </item>
  </channel>
</rss>
