<?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>Jan Varwig &#187; Gemfile</title>
	<atom:link href="http://jan.varwig.org/archive/tag/gemfile/feed" rel="self" type="application/rss+xml" />
	<link>http://jan.varwig.org</link>
	<description>Somewhere between Hello World and HAL9000</description>
	<lastBuildDate>Sat, 03 Dec 2011 00:15:10 +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>Rails 3 and Mongrel</title>
		<link>http://jan.varwig.org/archive/rails-3-and-mongrel?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rails-3-and-mongrel</link>
		<comments>http://jan.varwig.org/archive/rails-3-and-mongrel#comments</comments>
		<pubDate>Fri, 05 Feb 2010 16:12:18 +0000</pubDate>
		<dc:creator>Jan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[Gemfile]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails3]]></category>

		<guid isPermaLink="false">http://jan.varwig.org/?p=240</guid>
		<description><![CDATA[Today, the Rails team finally released the first beta of Rails 3. Trying to play around with it, I experienced a very annoying problem with mongrel: Per default, Rails seems to only work with the gems listed in its Gemfile, which means that it starts using webrick. I wanted it to use mongrel, like Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Today, the Rails team finally released the first beta of <a href="http://weblog.rubyonrails.org/2010/2/5/rails-3-0-beta-release">Rails 3</a>.
Trying to play around with it, I experienced a very annoying problem with mongrel:</p>

<p>Per default, Rails seems to only work with the gems listed in its Gemfile, which means that it starts using webrick.
I wanted it to use mongrel, like Rails 2 does and added <code>gem "mongrel"</code> to my gemfile which resulted in <code>rails server</code> just freezing.
The cuplrit was some of the weirdest piece of code I&#8217;ve ever seen, mongrel&#8217;s <code>Mongrel::Gems.require</code> function:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw1">def</span> <span class="kw3">require</span><span class="br0">&#40;</span>library, version = <span class="kw2">nil</span><span class="br0">&#41;</span><br />
&nbsp; <span class="kw1">begin</span><br />
&nbsp; &nbsp; <span class="kw4">Kernel</span>.<span class="kw3">require</span> library<br />
&nbsp; <span class="kw1">rescue</span> <span class="kw4">LoadError</span>, <span class="kw4">RuntimeError</span> =&gt; e<br />
&nbsp; &nbsp; <span class="kw1">begin</span> <br />
&nbsp; &nbsp; &nbsp; <span class="co1"># ActiveSupport breaks &#8216;require&#8217; by making it always return a true value</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw4">Kernel</span>.<span class="kw3">require</span> <span class="st0">&#8216;rubygems&#8217;</span><br />
&nbsp; &nbsp; &nbsp; version ? gem<span class="br0">&#40;</span>library, version<span class="br0">&#41;</span> : gem<span class="br0">&#40;</span>library<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">retry</span><br />
&nbsp; &nbsp; <span class="kw1">rescue</span> <span class="re2">Gem::LoadError</span>, <span class="kw4">LoadError</span>, <span class="kw4">RuntimeError</span><br />
&nbsp; &nbsp; &nbsp; <span class="co1"># puts &quot;** #{library.inspect} could not be loaded&quot; unless library == &quot;mongrel_experimental&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; <span class="kw1">end</span> &nbsp;<br />
<span class="kw1">end</span><br />
&nbsp;</div>

<p>An infinite loop with the only way out being an exception that never got thrown!</p>

<p>This madness was called from mongrel.rb:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="re0">$LOAD_PATH</span>.<span class="me1">unshift</span> <span class="st0">&#8216;projects/mongrel_experimental/lib/&#8217;</span><br />
<span class="re2">Mongrel::Gems</span>.<span class="kw3">require</span> <span class="st0">&#8216;mongrel_experimental&#8217;</span>, <span class="st0">&quot;&gt;=#{Mongrel::Const::MONGREL_VERSION}&quot;</span><br />
&nbsp;</div>

<p>Removing these two lines solved the issue. That would have meant patching my gems however, and that smells like something you should not do. The final solution was simple and posted in the comments of the Rails 3 Beta announcement by  Juanma Cervera. I just needed to add 3 more lines to my Gemfile:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
gem <span class="st0">&quot;mongrel&quot;</span><br />
gem <span class="st0">&quot;cgi_multipart_eof_fix&quot;</span><br />
gem <span class="st0">&quot;fastthread&quot;</span><br />
gem <span class="st0">&quot;mongrel_experimental&quot;</span><br />
&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://jan.varwig.org/archive/rails-3-and-mongrel/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

