


<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CantRemembrances &#187; aptana</title>
	<atom:link href="http://blog.cantremember.com/tag/aptana/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cantremember.com</link>
	<description>Memes of a technical vein discovered during CantRemember.com implementation</description>
	<lastBuildDate>Tue, 16 Feb 2010 06:36:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Custom Ruby and RadRails on Mac OS X</title>
		<link>http://blog.cantremember.com/custom-ruby-and-radrails-on-mac-os-x/</link>
		<comments>http://blog.cantremember.com/custom-ruby-and-radrails-on-mac-os-x/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 04:53:37 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[aptana]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=29</guid>
		<description><![CDATA[Let&#8217;s break this down, shall we &#8230;
Building Ruby and RubyGems
Many thanks to Dan Benjamin for his excellent posting on doing a custom build of Ruby &#38; RubyGems on OS X.  I was just getting started with using a Mac at the time, and it was a very straight-forward and helpful guide.  For most [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s break this down, shall we &#8230;</p>
<h3>Building Ruby and RubyGems</h3>
<p>Many thanks to <a href="http://danbenjamin.com/articles/2008/02/ruby-rails-leopard">Dan Benjamin</a> for his <strong>excellent</strong> posting on doing a custom build of Ruby &amp; RubyGems on OS X.  I was just getting started with using a Mac at the time, and it was a very straight-forward and helpful guide.  For most software, I&#8217;ll use <a href="http://www.macports.org/">MacPorts</a> or standard Apple packages, but for Ruby I&#8217;ll make an exception.</p>
<p>For starters, I just want to expand a bit on his excellent tutorial.  I won&#8217;t re-iterate his whole piece, but the outline is:</p>
<ul>
<li>start with OS X Leopard, and XCode (from your Optional Installs DVD)</li>
<li>get /usr/local and its derivatives into your path</li>
<li>set aside a good long-term home for your custom build code</li>
<li>pull down the source for <a href="http://ruby-lang.org">Ruby</a></li>
<li>run ./configure, then build and install with make</li>
<li>pull down the source for <a href="http://rubyforge.org/projects/rubygems/">RubyGems</a>, run its setup.rb</li>
</ul>
<p>After that you can install all of the <a href="http://rubygems.org">gems</a> that your heart desires.  I initially pulled down source for the Ruby 1.9 candidate release, but there are significant enough language changes that it destabilized a lot of tried-and-true gems.  Instead, I went with the latest generation of 1.8.7.</p>
<p>I did however run into a little issue when installing the native mysql gem.  Dan&#8217;s instructions weren&#8217;t valid for my case.  Fortunately, the README.html in the gem suggested building it manually as such:</p>
<div class="pre_wrap">
<pre><code>$ sudo gem install mysql -- --with-mysql-config
  <em>or</em>
$ ruby extconf.rb --with-mysql-config</code></pre>
</div>
<p>That worked well, since I&#8217;d already installed MySQL and my <code>/etc/mysql.cnf</code> was in its standard location.  Hooray!</p>
<h3>Configuring RadRails to use the Custom-Built Componentry</h3>
<p>Since I switch back and forth between Ruby and Java, I chose to stick with the Eclipse IDE.  <a href="http://aptana.com/">Aptana</a> has created a nice development suite called <a href="http://aptana.com/rails">RadRails</a> which is highly componentized, and it works rather well for script development as well.  Yes, if I don&#8217;t use <a href="http://macromates.com/">TextMate</a> I&#8217;m a heretic, but at some point I&#8217;ll hunker down and pony out the bucks for it :)</p>
<p>The install of Eclipse 3.4 Ganymede that I started out with contained several plugins / features from <code>rubypeople.org</code>.  As well intended as they were, I ran into several areas of conflict between them and RadRails.  I thus chose to remove these plugins from Eclipse, and stability ensued.</p>
<p>However, even after removed, I still have two Eclipse sections for &#8216;Ruby&#8217;.  The one for RadRails is the one with fewer sub-sections (also known as &#8216;the one that looks <em>less</em> like the Java language configuration section&#8217;).</p>
<p>Since you&#8217;ve custom built your install of Ruby, you&#8217;ll want to make the following configuration changes to Eclipse / RadRails:</p>
<ul>
<li>Under <strong>Ruby | Interpreters</strong>, add a new Generic Ruby interpreter.  Its executable should be <code>/usr/bin/local/ruby</code>, and the rest will take care of itself (I didn&#8217;t specify any arguments).</li>
<li>Under <strong>Rails</strong>, set up the &#8216;rails&#8217; and &#8216;mongrel_rails&#8217; paths to reference the respective binaries in <code>/usr/local/bin</code>, since that&#8217;s where all of your installed gems will have been exposed.</li>
<li>Under <strong>Java | Build Path | Classpath Variables</strong>, you&#8217;ll want to add <strong>GEM_LIB</strong>, which should reference <code>/usr/local/lib/ruby/gems/1.8/gems</code>.  It seems out of place under &#8216;Java&#8217;, but the IDE was crying out for it loudly.</li>
</ul>
<p>That should address the majority of the IDE configuration.  If anything doesn&#8217;t quite work correctly, you may want to examine the steps that I describe below as being &#8216;optional&#8217;, particularly the one where I created a mock <code>Ruby.framework</code> setup.</p>
<h3>Optional (?) Configuration</h3>
<p>I question whether they&#8217;re mandatory or not because this configuration has been stable on my machine for a little while now, and I have a tendency to get very detail-oriented, not all of which turns out to actually be <em>necessary</em>.  In the spirit of completeness &#8212; yep, there&#8217;s detail-oriented for you right there! &#8212; I&#8217;ll lay out what I have put into play.</p>
<p>I&#8217;ve injected &#8216;/usr/local/bin&#8217; and &#8216;/usr/local/sbin&#8217; into <code>/etc/paths</code>; that works like a charm.</p>
<p>I consistently install gems as root, or else I end up with account-specific discrepancies driven by each <code>~/.gems</code> folder.  I merely point that out to illustrate that such user-specific directories exists :)</p>
<p>I&#8217;ve added the following <i>unnecessary</i> env var:</p>
<div class="pre_wrap">
<pre><code>export GEM_LIB=/usr/local/lib/ruby/gems/1.8/gems</code></pre>
</div>
<p>It matches the Classpath Variable you set in Eclipse (above).  If nothing else, it&#8217;s an easy &#8216;$&#8217; substitution when I need to go spelunking into gem source code.</p>
<p>There&#8217;s been at least once where I have also needed the following env var.  It should be configured to point at the expanded source code of your custom Ruby build.</p>
<div class="pre_wrap">
<pre><code>export RUBY_SOURCE_DIR=...</code></pre>
</div>
<p>I&#8217;ve created the following directory structure:</p>
<div class="pre_wrap">
<pre><code>$ mkdir -p /System/Library/Frameworks/Ruby.framework/Versions/1.8-Current</code></pre>
</div>
<p>Therein I have created a &#8216;usr&#8217; directory structure that matches the one you&#8217;ll find in <code>/System/Library/Frameworks<wbr>/Ruby.framework/Versions/1.8/usr</code> .  It&#8217;s all just symlinks into the appropriate <code>/usr/local</code> hierarchy.  I then co-opted the Current symlink:</p>
<div class="pre_wrap">
<pre><code>$ cd /System/Library/Frameworks/Ruby.framework/Versions
$ ls -l
1.8
1.8-Current
Current -&gt; 1.8
$ rm Current
$ ln -s 1.8-Current Current</code></pre>
</div>
<p>Consider that you may need to mimic certain aspects of the default Ruby framework configuration, which is the inverse of the mock framework setup that I just described.  Specifically, <code>/usr/local/lib/ruby</code> takes after <code>/System/Library/Frameworks<wbr>/Ruby.framework/Versions/Current/usr/lib/ruby</code>.</p>
<p>This is why I ended up with both a &#8216;/usr/local/lib/ruby/site_ruby&#8217; and &#8216;/usr/local/lib/ruby/vendor_ruby&#8217; subdir on my machine.</p>
<p>The standard location for the <code>ruby</code> executable is often used in a she-bang line for <code>bash</code> scripts.  The standard location is:</p>
<div class="pre_wrap">
<pre><code>#!/usr/bin/ruby</code></pre>
</div>
<p>Which of course was still pointing at the default OS X Ruby framework.  I renamed the existing symlink and replaced it with one to <code>/usr/local/bin/ruby</code>.  I did not do this for <code>gem, irb, rdoc</code> (etc.) since I don&#8217;t have she-bang needs for them.</p>
<h3>In Summary</h3>
<p>I hope some of this information is useful to you.  I was sitting at <a href="http://www.cafeinternational.com/">Cafe International</a> and setting up RadRails when the HD on my two-week-old MacBook Pro 2008 went into beachball-of-death mode.  I had to pick back up from there 2+ weeks later on a fresh laptop, which at least allowed me to keep these copious notes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/custom-ruby-and-radrails-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
