<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>leonardoborges.com</title>
	
	<link>http://www.leonardoborges.com/writings</link>
	<description>the not so usual geek stuff...</description>
	<pubDate>Thu, 20 Nov 2008 20:30:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<geo:lat>40.3975</geo:lat><geo:long>-3.714044</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-nc-sa/2.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/leonardoborges" type="application/rss+xml" /><item>
		<title>Rails performance scripts: profiler and benchmarker</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/459980392/</link>
		<comments>http://www.leonardoborges.com/writings/2008/11/20/rails-performance-scripts-profiler-benchmarker/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 20:30:53 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Performance]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=84</guid>
		<description><![CDATA[There are several ways you can measure your rails application&#8217;s performance. The techniques range from filling your code with &#8220;puts&#8221; statements - :p - to fancy ones like NewRelic - which is quite nice, I must say.
But what many people don&#8217;t know is that rails ships with a handful of scripts to help you out. [...]]]></description>
			<content:encoded><![CDATA[<p>There are several ways you can measure your rails application&#8217;s performance. The techniques range from filling your code with &#8220;puts&#8221; statements - :p - to fancy ones like <a href="http://www.newrelic.com/">NewRelic</a> - which is quite nice, I must say.</p>
<p>But what many people don&#8217;t know is that rails ships with a handful of scripts to help you out. One of which is called <strong>profiler</strong>, located under your application&#8217;s <strong>scripts/performance</strong> directory.</p>
<p>By default it uses the standard ruby profiler but if you want more speed - and additional reporting options - , consider installing the <a href="http://ruby-prof.rubyforge.org/">ruby-prof</a> gem.</p>
<p>So if you execute it without params, you&#8217;ll get a clue of how it works:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ script<span style="color: #000000; font-weight: bold;">/</span>performance<span style="color: #000000; font-weight: bold;">/</span>profiler
Usage: .<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>performance<span style="color: #000000; font-weight: bold;">/</span>profiler <span style="color: #ff0000;">'Person.expensive_method(10)'</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">times</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>flat<span style="color: #000000; font-weight: bold;">|</span>graph<span style="color: #000000; font-weight: bold;">|</span>graph_html<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Pretty self explanatory, right?</p>
<p>As a sample code, I have in my rails app a dumb model with a really dumb method I wanna profile:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Article <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">find_all_with_delay</span>
    <span style="color:#CC0066; font-weight:bold;">sleep</span> <span style="color:#006666;">10</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Clearly this method doesn&#8217;t perform well and is a bottle neck in our super application! But let&#8217;s see what rails&#8217; profiler tells us:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="bash">$ script<span style="color: #000000; font-weight: bold;">/</span>performance<span style="color: #000000; font-weight: bold;">/</span>profiler <span style="color: #ff0000;">'Article.find_all_with_delay'</span> <span style="color: #000000;">1</span> graph <span style="color: #000000; font-weight: bold;">&gt;</span> text_graph.perf
Loading Rails...
Using the ruby-prof extension.
Thread ID: <span style="color: #000000;">109440</span>
Total Time: <span style="color: #000000;">10.147995</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">%</span>total   <span style="color: #000000; font-weight: bold;">%</span>self     total      self      <span style="color: #7a0874; font-weight: bold;">wait</span>     child            calls   Name
--------------------------------------------------------------------------------
 <span style="color: #000000;">100.00</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">0.00</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>                <span style="color: #000000;">1</span>     Global<span style="color: #666666; font-style: italic;">#[No method] (/Users/leo/projects/test/vendor/rails/railties/lib/commands/performance/profiler.rb:24}  /Users/leo/projects/test/vendor/rails/railties/lib/commands/performance/profiler.rb:24</span>
                     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     Object<span style="color: #666666; font-style: italic;">#profile_me</span>
--------------------------------------------------------------------------------
                     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     Global<span style="color: #666666; font-style: italic;">#[No method]</span>
 <span style="color: #000000;">100.00</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">0.00</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>                <span style="color: #000000;">1</span>     Object<span style="color: #666666; font-style: italic;">#profile_me ((eval):1}  (eval):1</span>
                      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     Class<span style="color: #666666; font-style: italic;">#const_missing</span>
                     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">&lt;</span>Class::Article<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span>: integer, name: string, content: string, created_at: datetime, updated_at: datetime<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #666666; font-style: italic;">#find_all_with_delay</span>
--------------------------------------------------------------------------------
                     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     Object<span style="color: #666666; font-style: italic;">#profile_me</span>
  <span style="color: #000000;">99.97</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">0.00</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">10.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>     <span style="color: #000000;">10.15</span>                <span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">&lt;</span>Class::Article<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span>: integer, name: string, content: string, created_at: datetime, updated_at: datetime<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #666666; font-style: italic;">#find_all_with_delay (/Users/leo/projects/test/app/models/article.rb:2}  /Users/leo/projects/test/app/models/article.rb:2</span>
                      <span style="color: #000000;">0.15</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.15</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">&lt;</span>Class::ActiveRecord::Base<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #666666; font-style: italic;">#find</span>
                     <span style="color: #000000;">10.00</span>     <span style="color: #000000;">10.00</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     Kernel<span style="color: #666666; font-style: italic;">#sleep</span>
--------------------------------------------------------------------------------
                     <span style="color: #000000;">10.00</span>     <span style="color: #000000;">10.00</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>     <span style="color: #000000; font-weight: bold;">&lt;</span>Class::Article<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span>: integer, name: string, content: string, created_at: datetime, updated_at: datetime<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #666666; font-style: italic;">#find_all_with_delay</span>
  <span style="color: #000000;">98.54</span><span style="color: #000000; font-weight: bold;">%</span>  <span style="color: #000000;">98.54</span><span style="color: #000000; font-weight: bold;">%</span>     <span style="color: #000000;">10.00</span>     <span style="color: #000000;">10.00</span>      <span style="color: #000000;">0.00</span>      <span style="color: #000000;">0.00</span>                <span style="color: #000000;">1</span>     Kernel<span style="color: #666666; font-style: italic;">#sleep (ruby_runtime:0}  ruby_runtime:0</span>
--------------------------------------------------------------------------------
...</pre></td></tr></table></div>

<p>As you can see, the group around line 13 is where most of the time is spent, going through our stupid call to Kernel#sleep and detailing every and each call from the very beginning. The report is much larger, so I recommend you give it a try. It&#8217;s really useful.</p>
<p>Now, displeased with my method&#8217;s performance, I wrote a new one that I think performs much better:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">find_all_with_less_delay</span>
    <span style="color:#CC0066; font-weight:bold;">sleep</span> <span style="color:#006666;">5</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Nice huh? <img src='http://www.leonardoborges.com/writings/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> But how can we be sure it performs better? It turns out that under <strong>scripts/performance</strong> there is another useful script: <strong>benchmarker</strong></p>
<p>Again, running it without arguments reveals it&#8217;s usage:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ script<span style="color: #000000; font-weight: bold;">/</span>performance<span style="color: #000000; font-weight: bold;">/</span>benchmarker 
Usage: .<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>performance<span style="color: #000000; font-weight: bold;">/</span>benchmarker <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">times</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">'Person.expensive_way'</span> <span style="color: #ff0000;">'Person.another_expensive_way'</span> ...</pre></div></div>

<p>So, ready to see which one of my methods performs better? Let&#8217;s check:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ script<span style="color: #000000; font-weight: bold;">/</span>performance<span style="color: #000000; font-weight: bold;">/</span>benchmarker <span style="color: #000000;">1</span> <span style="color: #ff0000;">'Article.find_all_with_delay'</span> <span style="color: #ff0000;">'Article.find_all_with_less_delay'</span>
            user     system      total        real
<span style="color: #666666; font-style: italic;">#1      0.020000   0.000000   0.020000 ( 10.016033)</span>
<span style="color: #666666; font-style: italic;">#2      0.010000   0.000000   0.010000 (  5.015390)</span></pre></div></div>

<p>Pretty neat way to benchmark your methods huh?<br />
Profiler and benchmarker are a powerful combination that have been helping me a lot in the projects I&#8217;m working on.</p>
<p>Hope you like it! See u soon! <img src='http://www.leonardoborges.com/writings/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/459980392" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/11/20/rails-performance-scripts-profiler-benchmarker/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/11/20/rails-performance-scripts-profiler-benchmarker/</feedburner:origLink></item>
		<item>
		<title>Merb turns 1.0, and started driving me crazy</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/457539534/</link>
		<comments>http://www.leonardoborges.com/writings/2008/11/18/merb-turns-10-and-started-driving-me-crazy/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 19:43:45 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Merb]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=81</guid>
		<description><![CDATA[As you may already know, Merb turned 1.0 a while ago and I decided to resume my studies to learn the framework.
So I just built a new app with a few resources and fired the migration scripts:

$ rake db:automigrate

And this is what I got:

Loading init file from /Users/leo/projects/merb/my-first-app/config/init.rb
Loading /Users/leo/projects/merb/my-first-app/config/environments/development.rb
 ~ Connecting to database...
/opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/adapters/data_objects_adapter.rb:137:in `initialize': wrong [...]]]></description>
			<content:encoded><![CDATA[<p>As you may already know, <a href="http://www.merbivore.com/">Merb</a> turned 1.0 a while ago and I decided to resume my studies to learn the framework.</p>
<p>So I just built a new app with a few resources and fired the migration scripts:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ rake db:automigrate</pre></div></div>

<p>And this is what I got:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">Loading init <span style="color: #c20cb9; font-weight: bold;">file</span> from <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>leo<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>merb<span style="color: #000000; font-weight: bold;">/</span>my-first-app<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>init.rb
Loading <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>leo<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>merb<span style="color: #000000; font-weight: bold;">/</span>my-first-app<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>environments<span style="color: #000000; font-weight: bold;">/</span>development.rb
 ~ Connecting to database...
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000;">-0.9</span><span style="color: #000000;">.6</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000; font-weight: bold;">/</span>adapters<span style="color: #000000; font-weight: bold;">/</span>data_objects_adapter.rb:<span style="color: #000000;">137</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>initialize<span style="color: #ff0000;">': wrong number of arguments (8 for 1) (ArgumentError)
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/adapters/data_objects_adapter.rb:137:in `new'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000;">-0.9</span><span style="color: #000000;">.6</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000; font-weight: bold;">/</span>adapters<span style="color: #000000; font-weight: bold;">/</span>data_objects_adapter.rb:<span style="color: #000000;">137</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>normalize_uri<span style="color: #ff0000;">'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/adapters/abstract_adapter.rb:44:in `initialize'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000;">-0.9</span><span style="color: #000000;">.6</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000; font-weight: bold;">/</span>adapters<span style="color: #000000; font-weight: bold;">/</span>data_objects_adapter.rb:<span style="color: #000000;">159</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>initialize<span style="color: #ff0000;">'
	from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core.rb:157:in `new'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>dm-core<span style="color: #000000;">-0.9</span><span style="color: #000000;">.6</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dm-core.rb:<span style="color: #000000;">157</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>setup<span style="color: #ff0000;">'
	from /opt/local/lib/ruby/gems/1.8/gems/merb_datamapper-1.0/lib/merb/orms/data_mapper/connection.rb:44:in `setup_connections'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>merb_datamapper<span style="color: #000000;">-1.0</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>merb<span style="color: #000000; font-weight: bold;">/</span>orms<span style="color: #000000; font-weight: bold;">/</span>data_mapper<span style="color: #000000; font-weight: bold;">/</span>connection.rb:<span style="color: #000000;">27</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>connect<span style="color: #ff0000;">'
	from /opt/local/lib/ruby/gems/1.8/gems/merb_datamapper-1.0/lib/merb_datamapper.rb:17:in `run'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>merb-core<span style="color: #000000;">-1.0</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>merb-core<span style="color: #000000; font-weight: bold;">/</span>bootloader.rb:<span style="color: #000000;">99</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>run<span style="color: #ff0000;">'
	from /opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0/lib/merb-core/server.rb:172:in `bootup'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>merb-core<span style="color: #000000;">-1.0</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>merb-core<span style="color: #000000; font-weight: bold;">/</span>server.rb:<span style="color: #000000;">42</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>start<span style="color: #ff0000;">'
	from /opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0/lib/merb-core.rb:169:in `start'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>merb-core<span style="color: #000000;">-1.0</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>merb:<span style="color: #000000;">11</span>
	from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>merb:<span style="color: #000000;">19</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>load<span style="color: #ff0000;">'
	from /opt/local/bin/merb:19
</span</pre></div></div>

<p>Lovely, isn&#8217;t it?<br />
After a fair amount of googling around it turns out that there seems to be a problem with the URI parser <a href="http://www.merbivore.com/">Merb</a> uses underneath, called <a href="http://addressable.rubyforge.org/">Addressable</a>.</p>
<p>As of the installation of Merb 1.0, the installed version of this library was 2.0.0.<br />
The solution? Install a older Addressable version:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem uninstall addressable
&nbsp;
You have requested to uninstall the gem:
	addressable<span style="color: #000000;">-2.0</span><span style="color: #000000;">.0</span>
dm-core<span style="color: #000000;">-0.9</span><span style="color: #000000;">.6</span> depends on <span style="color: #7a0874; font-weight: bold;">&#91;</span>addressable <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">1.0</span><span style="color: #000000;">.4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
data_objects<span style="color: #000000;">-0.9</span><span style="color: #000000;">.6</span> depends on <span style="color: #7a0874; font-weight: bold;">&#91;</span>addressable <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">1.0</span><span style="color: #000000;">.3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
If you remove this gems, one or <span style="color: #c20cb9; font-weight: bold;">more</span> dependencies will not be met.
Continue with Uninstall? <span style="color: #7a0874; font-weight: bold;">&#91;</span>Yn<span style="color: #7a0874; font-weight: bold;">&#93;</span>  Y
Successfully uninstalled addressable<span style="color: #000000;">-2.0</span><span style="color: #000000;">.0</span>
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> addressable -v <span style="color: #000000;">1.0</span><span style="color: #000000;">.4</span>
Successfully installed addressable<span style="color: #000000;">-1.0</span><span style="color: #000000;">.4</span>
<span style="color: #000000;">1</span> gem installed
Installing ri documentation <span style="color: #000000; font-weight: bold;">for</span> addressable<span style="color: #000000;">-1.0</span><span style="color: #000000;">.4</span>...
Installing RDoc documentation <span style="color: #000000; font-weight: bold;">for</span> addressable<span style="color: #000000;">-1.0</span><span style="color: #000000;">.4</span>...</pre></div></div>

<p>I haven&#8217;t figured out the reason for this issue, so please do share if you know. I&#8217;ll be glad to update the post. <img src='http://www.leonardoborges.com/writings/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/457539534" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/11/18/merb-turns-10-and-started-driving-me-crazy/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/11/18/merb-turns-10-and-started-driving-me-crazy/</feedburner:origLink></item>
		<item>
		<title>Understanding Ruby threads</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/435164282/</link>
		<comments>http://www.leonardoborges.com/writings/2008/10/28/understanding-ruby-threads/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 21:56:07 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=77</guid>
		<description><![CDATA[This post is just to clarify some confusion I&#8217;ve noticed reading some posts around the web. There is some misunderstanding of the differences between Ruby 1.8 and Ruby 1.9 regarding threads. And the difference between them and JRuby.
So I decided to write this small summary:
Ruby 1.8 - Supports only Green Threads
This means that the ruby [...]]]></description>
			<content:encoded><![CDATA[<p>This post is just to clarify some confusion I&#8217;ve noticed reading some posts around the web. There is some misunderstanding of the differences between Ruby 1.8 and Ruby 1.9 regarding threads. And the difference between them and JRuby.</p>
<p>So I decided to write this small summary:</p>
<p><strong>Ruby 1.8</strong> - Supports only <a href="http://en.wikipedia.org/wiki/Green_threads">Green Threads</a></p>
<p>This means that the ruby interpreter has its own scheduler. No matter how many threads you create in your ruby program, there will be only one native thread on your OS. Therefore, your program cannot take advantage of multiple core environments.</p>
<p><strong>Ruby 1.9</strong> - Supports native threads (GIL)</p>
<p>Ruby 1.9 adopted <a href="http://www.atdot.net/yarv/">YARV</a> as the new VM implementation, which supports native threads. This means that now your ruby programs can take advantage of multiple core environments, but no truly parallel execution is achieved.</p>
<p>The catch is GIL - Global Interpreter Lock - and it means that each ruby thread runs on its own native thread, but only one of them can be executed at a time.</p>
<p><strong>JRuby</strong> - Ruby 1.8 compatible</p>
<p>I think this is the easy part. JRuby runs on the Java VM, which supports native threads and parallel execution.</p>
<p>On this environment, ruby threads are java threads.</p>
<p><strong>The future</strong></p>
<p>There doesn&#8217;t seem to be any decision about what&#8217;s gonna happen on the next versions of Ruby. At least to the extent of my research. But this is today&#8217;s snapshot of Ruby threads and I hope it&#8217;ll be useful to some folks.</p>
<p>c u around</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/435164282" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/10/28/understanding-ruby-threads/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/10/28/understanding-ruby-threads/</feedburner:origLink></item>
		<item>
		<title>Don’t use REXML. I mean it.</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/415048211/</link>
		<comments>http://www.leonardoborges.com/writings/2008/10/08/dont-use-rexml-i-mean-it/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 18:43:44 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=75</guid>
		<description><![CDATA[REXML is the standard XML processing library for Ruby. It&#8217;s on Ruby&#8217;s core and is terribly slow.
Yeah, I know it&#8217;s pretty simple to use, got a nice interface and, again, it&#8217;s just there. And it is a good library, for most things. But if you, as me, came to a point that processing XML is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.germane-software.com/software/rexml/">REXML</a> is the standard XML processing library for Ruby. It&#8217;s on Ruby&#8217;s core and is terribly <strong>slow</strong>.</p>
<p>Yeah, I know it&#8217;s pretty simple to use, got a nice interface and, again, it&#8217;s just there. And it is a good library, for most things. But if you, as me, came to a point that processing XML is taking 50% of the time to render a rails action, it&#8217;s time to change.</p>
<p>My tip? Use <a href="http://libxml.rubyforge.org/">libxml</a> instead. The numbers on their home page speak for themselves. Try it yourself, you won&#8217;t be disappointed. And I&#8217;m really happy with the performance increase on our app.</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/415048211" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/10/08/dont-use-rexml-i-mean-it/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/10/08/dont-use-rexml-i-mean-it/</feedburner:origLink></item>
		<item>
		<title>We’re hiring</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/403666371/</link>
		<comments>http://www.leonardoborges.com/writings/2008/09/26/were-hiring/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 10:40:36 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Offers]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=72</guid>
		<description><![CDATA[Here at Mirai we&#8217;re looking for passionate software engineers.
And if it&#8217;s not clear, by passionate I mean people who actually enjoy their job, aren&#8217;t afraid of trying new things, likes to research/study, is up to date to what&#8217;s happening around them and is a true team player.
Interested? Hold on, click here to find out more [...]]]></description>
			<content:encoded><![CDATA[<p>Here at <a href="http://miraiespana.com/">Mirai</a> we&#8217;re looking for passionate software engineers.</p>
<p>And if it&#8217;s not clear, by passionate I mean people who actually enjoy their job, aren&#8217;t afraid of trying new things, likes to research/study, is up to date to what&#8217;s happening around them and is a true team player.</p>
<p>Interested? Hold on, click <a href="http://jobs.hotelsearch.com/">here</a> to find out more about the offer, as well as instructions on how to apply.</p>
<p>Doubts?  Send them to jobs@hotelsearch.com</p>
<p>ps. If you&#8217;ve been following my blog, you probably have already got a feeling of the sort of stuff that we do here&#8230;</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/403666371" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/09/26/were-hiring/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/09/26/were-hiring/</feedburner:origLink></item>
		<item>
		<title>RailsConf Europe 2008: impressions and highlights</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/387612791/</link>
		<comments>http://www.leonardoborges.com/writings/2008/09/09/railsconf-europe-2008-impressions-and-highlights/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 12:10:05 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[RailsConf2008]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=65</guid>
		<description><![CDATA[I&#8217;m back in Madrid again after the RailsConf and I think it&#8217;s time to say something about it.  
First off, the infrastructure provided by the conference was really great. The rooms, WiFi connection, food&#8230;  Really well organized.
Now to the sessions, highlights:
Tutorials (Tuesday)
- Meta-programming Ruby for fun and profit (Neal Ford, Patrick Farley)
The old and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m back in Madrid again after the RailsConf and I think it&#8217;s time to say something about it. <img src='http://www.leonardoborges.com/writings/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First off, the infrastructure provided by the conference was really great. The rooms, WiFi connection, food&#8230;  Really well organized.</p>
<p>Now to the sessions, highlights:</p>
<p><strong>Tutorials (Tuesday)</strong><br />
- <a href="http://nealford.com/downloads/Ford-Farley_Meta_programming_ruby-tutorial.pdf">Meta-programming Ruby for fun and profit</a> (Neal Ford, Patrick Farley)<br />
The old and good techniques that made Ruby so powerful. Here Neal and Patrick walked us through the main tricks to meta programming like open classes - and conditionally open them - , dynamically define methods, sending messages to objects and how Ruby can help test your Java code in a much easier way.</p>
<p>I&#8217;ve put the link to the slides but honestly I don&#8217;t think they&#8217;re too much useful without the talking.</p>
<p><strong>Sessions (Wednessday)</strong><br />
- EC2, MapReduce and Distributed processing (<a href="http://railspikes.com">Jonathan Dahl</a>)<br />
Jonathan explained the theory behind <a href="http://en.wikipedia.org/wiki/Mapreduce">MapReduce</a> using very simple ruby examples, providing the basics on how to distribute and paralelize tasks accross multiple machines.</p>
<p>He also introduced <a href="http://hadoop.apache.org/core/">Hadoop</a>, a platform built in Java that &#8220;lets one easily write and run     applications that process vast amounts of data&#8221;. What I liked the most was the simplicity he explained this subject. As of today, his presentation is not available online. Stay tuned as I&#8217;m gonna update this post with the links, as soon as they&#8217;re available.</p>
<p><strong>Sessions (Thursday)</strong><br />
- <a href="http://nealford.com/downloads/conferences/canonical/Neal_Ford-Debugging_and_Testing_the_Web_Tier.zip">Debugging &amp; Testing the Web Tier</a> (<a href="http://nealford.com">Neal Ford</a>)<br />
If you&#8217;ve been concerned about testing your app&#8217;s web tier lately, this presentation would probably not show you anything new. Neal talks about the need to debug and test javascript behaviour accross multiple browsers, using tools like <a href="http://getfirebug.com/">Firebug</a>, <a href="http://www.jsunit.net/">JSUnit</a> and <a href="http://selenium.openqa.org/">Selenium</a>. If you have no idea about what these tools are, please stop now and go evaluate them!</p>
<p>We are pretty concerned about testing on my actual job, but selenium tests can be a pain sometimes - a.k.a extremely slow. And what ends up happening is that they are forgotten. Developers only run the test suite if it&#8217;s not painful and it&#8217;s lightning fast. Here&#8217;s is where the highlight for this session comes: <a href="http://www.thefrontside.net/crosscheck">CrossCheck</a>.</p>
<p>The idea is to be able to test your javascript code accross multiple browsers without the need to launch them. In fact, you don&#8217;t even need a browser installed. The negative point is that it&#8217;s kinda fallen behind because now you can only test older versions of browsers. But since the project is getting a lot of traction, I&#8217;m pretty sure this will be solved soon.</p>
<p><strong>Conclusion</strong></p>
<p>My overall impression of the other sessions I attended is that some speakers just didn&#8217;t have time to properly prepare themselves, what made me think this years&#8217;s RailsConf wasn&#8217;t all that I expected.</p>
<p>But I also met interesting people and after all one of the key points in a conference is networking. <img src='http://www.leonardoborges.com/writings/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Definitely worth it though. And that&#8217;s why I took the time to provide this highlights.</p>
<p>c u soon</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/387612791" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/09/09/railsconf-europe-2008-impressions-and-highlights/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/09/09/railsconf-europe-2008-impressions-and-highlights/</feedburner:origLink></item>
		<item>
		<title>RailsConf Europe 2008: heading to berlin!</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/378974817/</link>
		<comments>http://www.leonardoborges.com/writings/2008/08/30/railsconf-europe-2008-heading-to-berlin/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 15:09:39 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Conferences]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=63</guid>
		<description><![CDATA[The title says it already.
On monday I&#8217;ll be going to Berlin to attend this year´s RailsConf.
This will be my first one and of course my expectations are pretty high!
As usual, after the conference I&#8217;ll try and give a summary of what happened there, providing as much content as I can.
Anyone else&#8217;s going???  
C u [...]]]></description>
			<content:encoded><![CDATA[<p>The title says it already.</p>
<p>On monday I&#8217;ll be going to Berlin to attend this year´s <a href="http://en.oreilly.com/railseurope2008/public/content/home">RailsConf</a>.</p>
<p>This will be my first one and of course my expectations are pretty high!</p>
<p>As usual, after the conference I&#8217;ll try and give a summary of what happened there, providing as much content as I can.</p>
<p>Anyone else&#8217;s going??? <img src='http://www.leonardoborges.com/writings/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>C u there!</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/378974817" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/08/30/railsconf-europe-2008-heading-to-berlin/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/08/30/railsconf-europe-2008-heading-to-berlin/</feedburner:origLink></item>
		<item>
		<title>Mac OS X: Getting MySQL and Rails to work</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/377391778/</link>
		<comments>http://www.leonardoborges.com/writings/2008/08/28/mac-os-x-getting-mysql-and-rails-to-work/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 19:23:53 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Mac]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=60</guid>
		<description><![CDATA[So I couldn&#8217;t resist and bought myself a MacBook Pro! It&#8217;s my first week with my new toy and I&#8217;m really enjoying it.
But I need to do something useful with it so I started to prepare it to be my new development platform, starting with Ruby/Rails + MySQL: Here is where the fun begins!
After I [...]]]></description>
			<content:encoded><![CDATA[<p>So I couldn&#8217;t resist and bought myself a MacBook Pro! It&#8217;s my first week with my new toy and I&#8217;m really enjoying it.</p>
<p>But I need to do something useful with it so I started to prepare it to be my new development platform, starting with Ruby/Rails + MySQL: Here is where the fun begins!</p>
<p>After I installed both Rails and MySQL, I fired up a terminal an typed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql</pre></div></div>

<p>&#8230;and here is what u get</p>

<div class="wp_syntax"><div class="code"><pre class="bash">ERROR: Failed to build gem native extension.</pre></div></div>

<p>If you google this error you will find a couple solutions and this is the one that worked for me:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #007800;">ARCHFLAGS=</span><span style="color: #ff0000;">&quot;-Os -arch x86_64 -fno-common&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql -- --with-mysql-<span style="color: #007800;">dir=</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>mysql
--with-mysql-<span style="color: #007800;">config=</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_config</pre></div></div>

<p>Now, confident enough, I created a sample rails app and tried to create the development database:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">leo$ rake db:create <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>leo<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
dyld: lazy symbol binding failed: Symbol not found: _mysql_init</pre></div></div>

<p>Doesn&#8217;t look happy yet huh? This took me a while to figure out but it turned out to be fairly simple.<br />
I have no idea why but after I installed the gem I had the file mysql.bundle in two different places:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Ruby<span style="color: #000000; font-weight: bold;">/</span>Gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000;">-2.7</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql.bundle
<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Ruby<span style="color: #000000; font-weight: bold;">/</span>Gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000;">-2.7</span><span style="color: #000000; font-weight: bold;">/</span>mysql.bundle</pre></div></div>

<p>The solution was to remove the first copy of the file. Now everything is working fine at this end!<br />
I really hope this is useful to someone!</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/377391778" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/08/28/mac-os-x-getting-mysql-and-rails-to-work/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/08/28/mac-os-x-getting-mysql-and-rails-to-work/</feedburner:origLink></item>
		<item>
		<title>Rails: Vulnerability on REXML</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/373322167/</link>
		<comments>http://www.leonardoborges.com/writings/2008/08/24/rails-vulnerability-on-rexml/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 09:27:03 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=57</guid>
		<description><![CDATA[REXML, the XML library uses by many ruby apps, including rails, has a vulnerability that requires an immediate patch on whatever rails version you&#8217;re using.
Details and instructions on the official rails weblog, here.
But basically, this is what you need to do:

gem install rexml-expansion-fix

Then, require rexml-expansion-fix in your rails&#8217;s app environment.rb file.
]]></description>
			<content:encoded><![CDATA[<p>REXML, the XML library uses by many ruby apps, including rails, has a vulnerability that requires an immediate patch on whatever rails version you&#8217;re using.</p>
<p>Details and instructions on the official rails weblog, <a href="http://weblog.rubyonrails.org/2008/8/23/dos-vulnerabilities-in-rexml">here</a>.</p>
<p>But basically, this is what you need to do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rexml-expansion-fix</pre></div></div>

<p>Then, require rexml-expansion-fix in your rails&#8217;s app environment.rb file.</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/373322167" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/08/24/rails-vulnerability-on-rexml/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/08/24/rails-vulnerability-on-rexml/</feedburner:origLink></item>
		<item>
		<title>Yes we do eat.</title>
		<link>http://feeds.feedburner.com/~r/leonardoborges/~3/365716317/</link>
		<comments>http://www.leonardoborges.com/writings/2008/08/15/yes-we-do-eat/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 14:36:41 +0000</pubDate>
		<dc:creator>Leonardo Borges</dc:creator>
		
		<category><![CDATA[World]]></category>

		<guid isPermaLink="false">http://www.leonardoborges.com/writings/?p=54</guid>
		<description><![CDATA[Besides the fact that I am a software developer, I do eat. I even enjoy doing so. Specially when I&#8217;m traveling.
That&#8217;s why i decided to put up a new weblog only for this kind of stuff - it&#8217;s called Travel tips - food &#038; stuff. Basically for friends and whoever else might be interested.
There I [...]]]></description>
			<content:encoded><![CDATA[<p>Besides the fact that I am a software developer, I do eat. I even enjoy doing so. Specially when I&#8217;m traveling.<br />
That&#8217;s why i decided to put up a new weblog only for this kind of stuff - it&#8217;s called <a href="http://travel.leonardoborges.com">Travel tips - food &#038; stuff</a>. Basically for friends and whoever else might be interested.</p>
<p>There I plan to share some nice restaurants I&#8217;ve been to. At least to start with.</p>
<p>Hope u like it!</p>
<img src="http://feeds.feedburner.com/~r/leonardoborges/~4/365716317" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leonardoborges.com/writings/2008/08/15/yes-we-do-eat/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.leonardoborges.com/writings/2008/08/15/yes-we-do-eat/</feedburner:origLink></item>
	</channel>
</rss>
