Rails Quick Tip: Temporarily Disable Spring
Here’s a quick Ruby on Rails development tip. Last night, after setting up Bcrypt for a project, I got a strange error when I ran my test suite:
22:57:29 - INFO - Running all specs
You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install
The strange thing was that I knew I’d installed it. I tried all of the things that I could think of, including:
- Checking the Gemfile, Gemfile.lock, and running Bundler
- Restarting the Rails server
- Uninstalling and Reinstalling the Bcrypt gem
- Checking the Active Support and Active Model files, to make sure the dependencies were correct (i.e., ‘bcrypt’ and not ‘bcrypt-rails’), and comparing them to the installed versions listed in my Gemfile and Gemfile.lock files
Finally, I came across this solution from Shaun Sweet:
make sure you not only run bundle install, but that you ALSO kill the server and reload it to make sure it then loads in the new gems. you can also check your gemfile for ‘spring’. if thats loaded too, you’ll want to comment that out, reload the server and try it then. that should take care of all possibilities.
I commented out the ‘spring’ gem in my Gemfile, and reloaded the Rails server (I didn’t need to run Bundler)…
And my tests passed! After that, I removed the commenting from my Gemfile, and restarted the server again.
Apparently, restarting the Rails server might not always be enough. After you’ve verified that the gem is correctly installed, temporarily disabling Spring might help.
If you enjoyed this post, you might want to subscribe, so you don't miss the next one!