Vendor/Gems and Rake

Today, I hit a little bump along the road of having a nice, simple checkout/run path in the Rails project I’m working on. The problem occurs when you don’t have a gem installed on the system, instead unpacking it into vendor/gems. In order for those to be included in the environment, you need to add everything underneath vendor/gems to the load_paths, something like this:

  config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
    File.directory?(lib = "#{dir}/lib") ? lib : dir

Unfortunately, the Rakefile only requires boot.rb and the load_paths aren’t updated. Since we are using Rcov, it was bombing out because the Rake task couldn’t be found. I had to add an additional line in the Rakefile, require(File.join(File.dirname(__FILE__), ‘config’, ‘environment’)) After that, everything worked just fine.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>