0
votes

Pulling my hair out on this. I'm running some rspec specs through rake using rspec's rake task. Its been working fine until I started getting this error message:

rake aborted!  
LoadError: cannot load such file -- rspec/core/rake_task

Here is the results of gem list | grep rspec

rspec (3.1.0)
rspec-core (3.1.7)
rspec-expectations (3.1.2)
rspec-mocks (3.1.3)
rspec-support (3.1.2)

and here is the line I'm using to include the rake task in my Rakefile

require 'rspec/core/rake_task'

I uninstalled all rspec gems and re-installed. Same error. As I mentioned I've been running these tests for a few months now without issue. There have been no changes to the environment and it runs in a VM so I can ensure it wasn't a coworker. What am I missing?

EDIT

I double checked my Gemfile.lock file all the gem versions are matching with the one in the upstream repo.

1

1 Answers

1
votes

First off, I recommend running your specs through the rspec command. It's far more flexible than running specs through rake and has less overhead. Running the specs through rake is still useful as part of a build pipeline (the kind of thing rake is good at).

You haven't provided sufficient information to definitely answer your question, but I can provide some suggestions:

  • Are you running rake via bundle exec rake? Bundler is designed to manage the load path at runtime after it installs your gems, and should ensure that the installed rspec-core/lib is on your load path.
  • You can add puts $LOAD_PATH.join("\n") to the top of your Rakefile to see what the load path is. Is rspec-core in the list anywhere? (I suspect it's not). If it's not, then require 'rspec/core/rake_task' is not going to work unless rspec-core is installed as a system gem. Use gem which rspec-core to see if it's installed that way.