<?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>Carl Mercier&#039;s blog &#187; install_gems</title>
	<atom:link href="http://blog.carlmercier.com/tag/install_gems/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.carlmercier.com</link>
	<description>me = entrepreneur + hacker;</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:38:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Announcing install_gems.rb</title>
		<link>http://blog.carlmercier.com/2008/10/13/announcing-install_gemsrb/</link>
		<comments>http://blog.carlmercier.com/2008/10/13/announcing-install_gemsrb/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 15:50:53 +0000</pubDate>
		<dc:creator>Carl Mercier</dc:creator>
				<category><![CDATA[Defensio]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[install_gems]]></category>
		<category><![CDATA[install_gems.rb]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://blog.carlmercier.com/?p=154</guid>
		<description><![CDATA[Over the weekend, I was rethinking the way we should deploy our Merb application (our API) for Defensio. Everything I&#8217;ll say here applies to Rails as well. Managing gems has been painful lately. Like most people, we&#8217;re freezing them, which helps tremendously. However, there&#8217;s a few problems with this approach: We can&#8217;t freeze C extensions [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend, I was rethinking the way we should deploy our Merb application (our API) for <a href="http://defensio.com" target="_blank">Defensio</a>.  Everything I&#8217;ll say here applies to Rails as well.</p>
<p>Managing gems has been painful lately.  Like most people, we&#8217;re freezing them, which helps tremendously.  However, there&#8217;s a few problems with this approach:</p>
<ul>
<li>We can&#8217;t freeze C extensions because they need to be compiled for the target platform.  We develop on OS X and Linux 64, but deploy to Linux i386.  As a workaround, we currently freeze but recompile them on every deployment.  Definitely not optimal.</li>
<li>Our frozen gems directory is getting huge.</li>
<li>It&#8217;s becoming complicated and quite a mess to manage multiple gem versions for different branches/tags.</li>
<li>We never quite know which branch needs which gem.</li>
</ul>
<p>Of course, we could manually install the gems we need on our servers.  But the word &#8220;manually&#8221; generally leads to &#8220;epic fail&#8221;.</p>
<p>So I thought, why not install them at deployment time, just before restarting the Mongrels, with Capistrano?  That seemed like a pretty good idea!  The only problem is that Rubygems will always install a gem when asked to do so, even if it&#8217;s already installed.</p>
<p>That&#8217;s where <a href="http://github.com/karabunga/install_gems/tree/master" target="_blank">install_gems.rb</a> comes in.  install_gems.rb takes a file name as an argument.  This file contains a simple list of gems along with their version number.  A custom installation command can also be specified.</p>
<p>Here&#8217;s an example:<br />
<code><br />
# This is an example file.  As you can see, it supports comments.<br />
haml 2.0.3<br />
eventmachine 0.12.2<br />
# Notice the custom command specified after the --<br />
termios 0.9.4 -- gem install termios -v 0.9.4 --no-rdoc --no-ri</p></blockquote>
<p></code></p>
<p>To install the above gems, you&#8217;d simply run<br />
<code>./install_gems.rb input_file</code></p>
<p>install_gems.rb has a few advantages over vanilla rubygems:</p>
<ul>
<li>It will only install a gem if the specified version is not already installed. That&#8217;s obviously much faster than reinstalling everything every time.</li>
<li>C extensions will be properly compiled.</li>
<li>Using different gem versions in different branches/tags/releases is now very easy.  You just have to maintain a list of required gems in your Git repository and make sure Capistrano runs install_gems.rb against this list before restarting the application servers.</li>
<li>It forces us to keep an up-to-date list of the gems we need.</li>
</ul>
<p>Of course, for this to work as expected, you&#8217;ll need to require specific gem versions in your application.  Your production server will likely have multiple versions of the same gems installed and if you don&#8217;t specify which version of the gem you want to require, things might (or will) break.</p>
<p>I released <a href="http://github.com/karabunga/install_gems/tree/master" target="_blank">install_gems.rb on GitHub</a> and <a href="http://danielharan.com" target="_blank">Daniel Haran</a> has already submitted a patch.  Feel free to do so as well, I&#8217;m a puller!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlmercier.com/2008/10/13/announcing-install_gemsrb/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

