[Ruby] cannot load such file -- ci/reporter/rake/rspec

Tadashi Shigeoka ·  Fri, November 9, 2012

When deploying Ruby on Rails with Capistrano, the following error occurred during execution of bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile, so here’s a memo of the solution.

■ Error message

cannot load such file -- ci/reporter/rake/rspec

Since ci_reporter is a gem that’s only installed in development and test environments, I added code to catch LoadError exceptions in the Rakefile to make it work in production environment as well.

% cat Rakefile 
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

begin
  require 'ci/reporter/rake/rspec'
rescue LoadError
end

myapp::Application.load_tasks

That’s all from the Gemba.