Search code examples
ruby-on-railsrake

Rake says "Don't know how to build task X", but "rake -T" lists it anyway - why?


I have a new OS X El Capitan setup with Ruby 2.2 (Macports), Rails 4.2.4 and Bundler for an existing app. Among a lot of other gems, this app uses parallel_tests to make good use of my 8-core machine. rake -T lists all the parallel test and spec tasks fine and in the past I could execute them. But when I do this now, after the upgrade, I just get

$ /opt/local/bin/rake parallel:prepare --trace
rake aborted!
Don't know how to build task 'parallel:prepare'
/opt/local/lib/ruby2.2/2.2.0/rake/task_manager.rb:62:in `[]'
/opt/local/lib/ruby2.2/2.2.0/rake/application.rb:149:in `invoke_task'

What can cause a task to be listed in rake -T, but not be found when I try to execute it?


Solution

  • In this case, the reason was that I had put the gem in question inside a group :test in my Gemfile. Apparently this caused the problem, removing it from the group and making it available globally resolved the problem (after calling bundle again).

    I don't know whether this is a generic solution, however.