Rails 5 - Could not find generator 'rspec:install'

Turns out its an issue with spring gem in my case. Restarting spring solved the problem.

First run bin/spring status. If spring is running you will get something similar:

Spring is running:

    8774 spring server | chessboard | started 14 mins ago   
    8808 spring app    | chessboard 6.52.08 PM | started 12 mins ago | development mode

That means you have to stop spring by running:

bin/spring stop

Then start it again:

bin/spring server

Then run rails generate rspec:install and it should work.

You may need to run bundle update.


I faced the same problem today and as it turned out I forgot to add rspec gem in my Gemfile.

Adding following line in the Gemfile solved the issue.

gem "rspec-rails"

Needed to do the same for foundation (rails g foundation:install Y)

gem 'foundation-rails'

Once added run bundle to update dependencies.

No need to restart spring.