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

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

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.

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.” [email protected]

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.” [email protected]

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

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.