


<?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; eclipse</title>
	<atom:link href="http://blog.cantremember.com/tag/eclipse/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>Sun, 07 Nov 2010 00:20:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>
		<item>
		<title>Getting Java SE 6 and Eclipse to play nicely on Mac OS X</title>
		<link>http://blog.cantremember.com/java-6-eclipse-os-x-leopard/</link>
		<comments>http://blog.cantremember.com/java-6-eclipse-os-x-leopard/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 23:44:16 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=19</guid>
		<description><![CDATA[Specifically, this post is about getting the standard pre-packaged install of Java SE 6 for OS X Leopard to play nicely with Eclipse 3.4 Ganymede. If you wish to move to Java SE 6 for Tiger or a pre-10.5 release of OS X, you may want to consider using SoyLatte, as recommended by the 2 [...]]]></description>
			<content:encoded><![CDATA[<p>Specifically, this post is about getting the standard pre-packaged install of Java SE 6 for OS X Leopard to play nicely with Eclipse 3.4 Ganymede.  If you wish to move to Java SE 6 for Tiger or a pre-10.5 release of OS X, you may want to consider using <a href="http://landonf.bikemonkey.org/static/soylatte/">SoyLatte</a>, as <a href="http://2tbsp.com/node/106">recommended by the 2 tablespoons blog</a>. I don&#8217;t imagine that any 3.x version of Eclipse would raise additional issues.</p>
<p>When you unpack the installer .dmg, it&#8217;s simply going to install the package.  It will not automatically assume that you want to use it (not such a bad assumption, as it turns out).  So there are a few caveats you need to deal with.  I&#8217;m taking the approach of addressing all the details I know of, regardless of how obvious this may all seem :)</p>
<p>Post-install, Java 5 will still be in active use:</p>
<div class="pre_wrap">
<pre><code>$ ls -l /usr/bin/java
/usr/bin/java -&gt; /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
$ Lunditer:~ root# java -version
java version "1.5.0_16"</code></pre>
</div>
<p>You&#8217;ll see something much like this under <code>/System/Library/Frameworks<wbr>/JavaVM.framework/Versions</code> :</p>
<div class="pre_wrap">
<pre><code>1.3 -&gt; 1.3.1
1.3.1
1.4 -&gt; 1.4.2
1.4.1 -&gt; 1.4
1.4.2
1.5 -&gt; 1.5.0
1.5.0
1.6.0
A
Current -&gt; A
CurrentJDK -&gt; 1.5</code></pre>
</div>
<p>Initially, I went and modified the symlink for CurrentJDK.  Modifying the symlink for Current brought me nothing but <em>pain</em>. You can get the results you want by making the following change:</p>
<div class="pre_wrap">
<pre><code>CurrentJDK -&gt; 1.6.0</code></pre>
</div>
<p>I&#8217;d had it set up that way until I wrote this post.  But Apple <a href="http://www.macosxhints.com/article.php?story=2005111606295344">highly discourages this practice</a>.  Instead, they recommend that you use the Java Preferences pane.  Get rid of all your symlink shenanigans, and simply drag the &#8216;Java SE 6&#8242; option to the top of the applet and application listings.  It works like a charm.  Start a new Terminal shell and you can confirm:</p>
<div class="pre_wrap">
<pre><code>$ /usr/bin/java -version
java version "1.6.0_07"
$ /usr/bin/javac -version
javac 1.6.0_07</code></pre>
</div>
<p>However &#8230; from my experience, this is a <em>user-specific</em> setting.  Which means if you run Java as <code>root</code>, you&#8217;ll still get Java SE 1.5.  Not a problem.  We&#8217;ll stick with the Apple-sanctioned solution here.</p>
<p>Hooray, Java SE 6!  Now let&#8217;s start Eclipse 3.4!  Hooray &#8230; oops?  Startup failure dialog:</p>
<div class="pre_wrap">
<pre><code>JVM terminated.
Exit code=-1
...
-vm /System/Library/Frameworks/JavaVM.framework
...</code></pre>
</div>
<p>This is a <strong>well documented</strong> issue.  Both the <a href="http://blog.kischuk.com/2008/05/08/running-eclipse-on-macbooks-with-java-6/">Rob Kischuk</a> and <a href="http://stackoverflow.com/questions/245803/jvm-terminates-when-launching-eclipse-mat-on-mac-os-with-j2se-60">Stack Overflow</a> blogs are very helpful in explaining that; Eclipse uses 32-bit SWT-Cocoa / Carbon, and Mac OS Java SE 6 only comes in a 64-bit flavor.  I have not looked into the SoyLatte option, as suggested above, though that may prove to be an alternative approach.</p>
<p>I had some struggles getting their approach to work (until now, that is).  Easiest way to start config testing is to run Eclipse from the command line:</p>
<div class="pre_wrap">
<pre><code>$ cd /Applications/eclipse/Eclipse.app/Contents/MacOS/
$ ./eclipse -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</code></pre>
</div>
<p>You can also provide <code>/System/Library/Frameworks<wbr>/JavaVM.framework/Versions/1.5.0</code>, which I extrapolated from the -vm setting in the failure message.  If you still get an error dialog, you may see multiple instances of -vm, but that&#8217;s a red herring; it will work once properly configured.</p>
<p>Great.  Once that&#8217;s working for you, let&#8217;s apply it to the App shortcut.  There&#8217;s two ways you can go about this:</p>
<p>The blogs above recommend that you modify the <code>Info.plist</code>:</p>
<ul>
<li>edit /Applications/eclipse/Eclipse.app/Contents/Info.plist</li>
<li>uncomment the following line:
<div class="pre_wrap">
<pre><code>&lt;string&gt;-vm&lt;/string&gt;&lt;string&gt;/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java&lt;/string&gt;</code></pre>
</div>
</li>
</ul>
<p>Alternately, you can modify <code>eclipse.ini</code>, where you might also configure your JVM memory configuration:</p>
<ul>
<li>edit /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini</li>
<li>add the following line:
<div class="pre_wrap">
<pre><code>-vm /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</code></pre>
</div>
</li>
</ul>
<p>Either dab will do ya.  But if you didn&#8217;t know before, now you know where <code>eclipse.ini</code> lives :)</p>
<p>Things should be grand now.  If they aren&#8217;t, I suggest trying some variations while running Eclipse from the command line.  It took me a while to get the right combination, even though this post and (the ones it references) may seem very cookie-cutter.  It <em>will</em> eventually work for you!</p>
<p>Now, I mentioned that the Apple-sanctioned approach seems to be user-specific.  And I run Tomcat as root.  So you will probably still want to add the traditional environment settings.</p>
<p>You can either make these changes to <code>/etc/profile</code>, or to the <code>~/.bashrc</code> of each relevant account.  No surprises here:</p>
<div class="pre_wrap">
<pre><code>export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
PATH="$JAVA_HOME/bin:$PATH"</code></pre>
</div>
<p>My experiments to get <code>/etc/paths</code> to inject something into the path before &#8216;/usr/bin&#8217; weren&#8217;t so useful, so I chose the brute force method.</p>
<p>If you&#8217;re going to use sudo to run Tomcat, you&#8217;ll want to make sure to load the bash environment.</p>
<div class="pre_wrap">
<pre><code>sudo su -</code></pre>
</div>
<p>to guarantee that root&#8217;s environment includes the custom /etc/profile overrides.  No dash, and it no work.  Tomcat Java 5 + App Java 6 =</p>
<div class="pre_wrap">
<pre><code>SEVERE: Error deploying web application directory ...
java.lang.UnsupportedClassVersionError: Bad version number in .class file</code></pre>
</div>
<p>With the environment in place, you should be good to go.</p>
<p>The writing of this post drove me to (a) drop the symlinks, (b) use Java Preferences pane and (c) get the right -vm config set up (since I&#8217;d been leaning entirely on the environment settings up to this point).  So there are definitely a few ways to skin this cat.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/java-6-eclipse-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

