<?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>rel=me &#187; gems</title>
	<atom:link href="http://rel.me/t/gems/feed/" rel="self" type="application/rss+xml" />
	<link>http://rel.me</link>
	<description>programming, objective-c, cocoa, iphone, c</description>
	<lastBuildDate>Wed, 01 Feb 2012 07:26:50 +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>Freezing gems with Gem.use_path</title>
		<link>http://rel.me/2008/04/09/freezing-gems-with-gem-use-path/</link>
		<comments>http://rel.me/2008/04/09/freezing-gems-with-gem-use-path/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 17:12:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">/2008/04/09/freezing-gems-with-gem-use-path</guid>
		<description><![CDATA[Edge rails now has gem dependency support built in, with tasks to freeze in vendor/gems. I have tried a bunch of different methods, and things like setting $GEM_HOME or using gemsonrails work well. But lately I have been using the Gem.use_paths method. If you put this in the config/environments rb: Gem.use_paths&#40;nil, &#91; &#34;#{RAILS_ROOT}/vendor/rubygems&#34; &#93;&#41; # [...]]]></description>
			<content:encoded><![CDATA[<p>Edge rails now has <a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies">gem dependency</a> support built in, with tasks to freeze in vendor/gems.</p>
<p>I have tried a bunch of different methods, and things like setting <tt>$GEM_HOME</tt> or using <a href="http://gemsonrails.rubyforge.org/">gemsonrails</a> work well. But lately I have been using the Gem.use_paths method.</p>
<p>If you put this in the config/environments rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">Gem.<span class="me1">use_paths</span><span class="br0">&#40;</span><span class="kw2">nil</span>, <span class="br0">&#91;</span> <span class="st0">&quot;#{RAILS_ROOT}/vendor/rubygems&quot;</span> <span class="br0">&#93;</span><span class="br0">&#41;</span>
<span class="co1"># Gem.path is now:</span>
<span class="co1"># [&quot;/Users/ghandford/Projects/my_rails_proj/vendor/rubygems&quot;, &quot;/Library/Ruby/Gems/1.8&quot;]</span></pre></div></div>

<p>The vendor/rubygems directory is the same structure as system gems folder:</p>

<div class="wp_syntax"><div class="code"><pre class="text">  vendor/rubygems/cache
  vendor/rubygems/doc
  vendor/rubygems/gems
  vendor/rubygems/specifications</pre></div></div>

<p>The convention I use is any non-native gems get frozen with the project, and then all the native gems go in the system gem path, which gets you pretty close to clone/checkout and rake setup.</p>
<p>As far as unpacking and install gems, you just use <tt>gem install</tt> with GEM_HOME of your local project:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="re2">GEM_HOME</span>=<span class="sy0">`</span><span class="kw3">pwd</span><span class="sy0">`/</span>vendor<span class="sy0">/</span>rubygems gem <span class="kw2">install</span> capitate</pre></div></div>

<p>A benefit of the use_paths method is that you can create scripts in your Rails project that use gems frozen in your project (and not necessarily have to require rails or environment.rb to get at them).</p>
<pre>
./script/my_non_rails_script
</pre>

<div class="wp_syntax"><div class="code"><pre class="ruby">  <span class="kw3">require</span> <span class="st0">'rubygems'</span>
  Gem.<span class="me1">use_paths</span><span class="br0">&#40;</span><span class="kw2">nil</span>, <span class="br0">&#91;</span> <span class="kw4">File</span>.<span class="me1">dirname</span><span class="br0">&#40;</span><span class="kw2">__FILE__</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;/../vendor/rubygems&quot;</span> <span class="br0">&#93;</span><span class="br0">&#41;</span></pre></div></div>

<p>Has anyone else tried this before?</p>
]]></content:encoded>
			<wfw:commentRss>http://rel.me/2008/04/09/freezing-gems-with-gem-use-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

