# Using gems:unpack into vendor/gems still requires the gems to be installed via gems:install

**URL:** <https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546>\
**Category:** Rails\
**Created:** [June 26, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546 "2008-06-26T22:49:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-oakes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@ben-oakes](https://www.ruby-forum.com/u/ben-oakes)\
**Post date:** [June 26, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546/1 "2008-06-26T22:49:24Z")

</div>

Maybe I’m missing something, but why do gem dependencies that have  
been unpacked into vendor/gems have to be installed on the machine as  
well? This doesn’t make much sense to me – if the gems are already  
on the machine, why does Rails still tell me to rake gems:install even  
when a gem is frozen into vendor/gems, but not on the machine?

This has become an issue because we want our CruiseControl.rb builds  
to have the correct gems, but getting them installed automatically is  
a bit of a pain. (If anyone has a good solution for this, please let  
me know – I’m not finding much of anything about these problems.)

Thanks for your input.

– Ben

---

<div class="post-metadata">

**Author:** ![ben-oakes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@ben-oakes](https://www.ruby-forum.com/u/ben-oakes)\
**Post date:** [June 27, 2008, 12:44am UTC](https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546/2 "2008-06-27T00:44:09Z")

</div>

Ben Oakes wrote:

> Maybe I’m missing something, but why do gem dependencies that have  
> been unpacked into vendor/gems have to be installed on the machine as  
> well? This doesn’t make much sense to me – if the gems are already  
> on the machine, why does Rails still tell me to rake gems:install even  
> when a gem is frozen into vendor/gems, but not on the machine?
> 
> This has become an issue because we want our CruiseControl.rb builds  
> to have the correct gems, but getting them installed automatically is  
> a bit of a pain. (If anyone has a good solution for this, please let  
> me know – I’m not finding much of anything about these problems.)
> 
> Thanks for your input.
> 
> – Ben

Maybe you need to add something like this to environment.rb:

config.load\_paths += Dir["#{RAILS\_ROOT}/vendor/gems/\*\*"].map do |dir|  
File.directory?(lib = “#{dir}/lib”) ? lib : dir  
end

- Ivan V.

---

<div class="post-metadata">

**Author:** ![ben-oakes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@ben-oakes](https://www.ruby-forum.com/u/ben-oakes)\
**Post date:** [June 27, 2008, 5:45pm UTC](https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546/3 "2008-06-27T17:45:03Z")

</div>

That might do it, but pretty much every rake task would still say gems  
need to be installed via rake gems:install. (Haven’t tested this  
though.)

– Ben

On Jun 26, 5:44 pm, “Ivan V.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ben-oakes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@ben-oakes](https://www.ruby-forum.com/u/ben-oakes)\
**Post date:** [June 27, 2008, 7:43pm UTC](https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546/4 "2008-06-27T19:43:27Z")

</div>

Ben Oakes wrote:

> That might do it, but pretty much every rake task would still say gems  
> need to be installed via rake gems:install. (Haven’t tested this  
> though.)
> 
> – Ben
> 
> On Jun 26, 5:44ï¿½pm, “Ivan V.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

If you have your gems frozen, why would you need to require them on your  
environment? Maybe you can comment them out until Rails can detect when  
they’re frozen.

- Ivan

---

<div class="post-metadata">

**Author:** ![ben-oakes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@ben-oakes](https://www.ruby-forum.com/u/ben-oakes)\
**Post date:** [June 28, 2008, 3:43pm UTC](https://www.ruby-forum.com/t/using-gems-unpack-into-vendor-gems-still-requires-the-gems-to-be-installed-via-gems-install/141546/5 "2008-06-28T15:43:08Z")

</div>

You’re using Rails 2.1, right? Gems that are unpacked shouldn’t need  
to also be installed on the machine. Are you trying to use a gem like  
this:

require “hpricot”  
task :some\_task\_that\_needs\_hpricot do  
…  
end

If so, the problem is that the Rails environment hasn’t loaded to put  
the gems in vendor/gems into your load path when you’re trying to  
require “hpricot.” If that’s the problem, I would lazy load the gems  
in tasks that depend on the :environment task.

task :hpricot =\> :environment do  
require “hpricot”  
end  
task :some\_task\_that\_needs\_hpricot =\> :hpricot do  
…  
end

-Dan M.
