rails-rspec error cannot load such file -- rspec/core/formatters/progress_formatter

Ruby on-Rails-4Rspec Rails

Ruby on-Rails-4 Problem Overview


I've broken my rails-rspec. I switched to a different gemset to run a 3rd party test. When I returned to my 2.3.0(default) gemset, I had the following errors.

running rspec gets:

/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- rspec/core/formatters/progress_formatter (LoadError)

running rails generate rspec:install returns:

Could not find generator 'rspec:install'. Maybe you meant 'devise:install' or ...

I have tried uninstalling and reinstalling, but errors persist.

Running rspec -v returns:

- rspec-core 3.6.0
- rspec-expectations 3.6.0
- rspec-mocks 3.6.0
- rspec-rails 3.6.1
- rspec-support 3.6.0

It seems that ruby cannot find rspec-core. I have tried the workaround from this post without success. Thank you in advance for any insight you might provide.

Running

> rails 4.2.0, ruby 2.3.0

Ruby on-Rails-4 Solutions


Solution 1 - Ruby on-Rails-4

Running bundle exec rspec solved it for me.

Solution 2 - Ruby on-Rails-4

Running bundle clean --force did the trick for me, turns out there's some outdated gem in my system

Solution 3 - Ruby on-Rails-4

I learned this from Victor Hazbun - expert on CodeMentor and Egghead.io:

Run gem list | grep rspec and pay attention to any gems that list multiple versions.

Then run gem uninstall ______ for each of those versions (removing ALL of the versions of each).

Then run bundle afterward. This will sync your versions with the versions in your gemfile.

Solution 4 - Ruby on-Rails-4

I was getting the error below in a rails app and none of the solutions here worked for me.

gems/rspec-core-3.8.0/lib/rspec/core/formatters.rb:210:in `require': cannot load such file -- rspec/core/formatters/progress_formatter (LoadError)

Emptying the gemset and re-installing did.

This assumes you are using rvm and a .ruby-gemset at the root of your app.

$ rvm gemset empty <name-of-gemset>
$ bundle install

Solution 5 - Ruby on-Rails-4

I think you should try

bundle exec rspec:install

Solution 6 - Ruby on-Rails-4

I was trying to make a contribution to CocoaPods and was getting the same error when I was doing rspec foo_spec.rb. Turns out they were NOT using rpsec at all. They seem to have had a special test runner:

> CocoaPods uses bacon as a test runner. To run all tests, use bundle exec rake spec in the root of the project. If you want to run a specific test instead, use bundle exec bacon spec/[folder]/[name]_spec.rb

For more on that see here

Solution 7 - Ruby on-Rails-4

If you run the specs from RubyMine, you can specific the RSpec version in Run Configuration.

Configuration Modifications

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSawyer MerchantView Question on Stackoverflow
Solution 1 - Ruby on-Rails-4lafeberView Answer on Stackoverflow
Solution 2 - Ruby on-Rails-4AxelView Answer on Stackoverflow
Solution 3 - Ruby on-Rails-4Jeremy MoritzView Answer on Stackoverflow
Solution 4 - Ruby on-Rails-4Joel SugarmanView Answer on Stackoverflow
Solution 5 - Ruby on-Rails-4escrayView Answer on Stackoverflow
Solution 6 - Ruby on-Rails-4mfaaniView Answer on Stackoverflow
Solution 7 - Ruby on-Rails-4aristotllView Answer on Stackoverflow