Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install - (I DO?)

I am trying to add has_secure password to my user.rb model

However when i run the bin/rspec to test this works/fails i am receiving the following error message in terminal

You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install
/Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/rubygems_integration.rb:256:in `block in replace_gem': bcrypt-ruby is not part of the bundle. Add it to Gemfile. (Gem::LoadError)

I have the gem: gem 'bcrypt', '~> 3.1.2' installed and have also tried to install and bundle the gem: bcrypt-ruby As the error message instructs, but this just tells me that the gem is now called bcrypt (as per my gem file)

Any ideas?

Thanks

Gary

I have also tried adding another gem into the gem file: gem 'bcrypt-ruby', '~>3.0.0'

but still receiving an error:

You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install
/Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/rubygems_integration.rb:266:in `block in replace_gem': can't activate bcrypt-ruby (~> 3.1.2), already activated bcrypt-ruby-3.0.1. Make sure all dependencies are added to Gemfile. (Gem::LoadError)

Have also tried deleting my Gemfile.lock and re running bundle install (Still No Change)

2 Answers

Did the tutorial use a different version of bcrypt-ruby? Not sure if this is still true, but ActiveModel's SecurePassword used to have a dependency on a specific version of 'bcrypt'.

Here's a link to a Stack Overflow post about it:

http://stackoverflow.com/questions/17741040/cant-activate-bcrypt-ruby-3-0-0-already-activated-bcrypt-ruby-3-1-1-make

Here's the answer I saw that might help you:

"In your gemfile, you aren't specifying the version, so you're installing the latest version of bcrypt-ruby which is 3.1.1, but what you need is any version from 3.0.0 to 3.0.9. You can get this by adding a version constraint like so:

gem 'bcrypt-ruby', '~> 3.0.0' The version requirement comes from ActiveModel's SecurePassword which currently has an explicit dependency on bcrypt-ruby (~> 3.0.0). You can see the dependency on github. When this code is executed, it looks for a version 3.0.0 through 3.0.9 which is not installed and so it throws an error.

This dependency was just updated to '~> 3.1.0' a couple of days ago, but has not made its way into the rails activemodel gem yet. When it does, you'll have to update your version accordingly."

Hi Julie,

Yes i saw this on Stack Overflow - have gone through a few of the posts on there, but to no avail.

Getting really frustrated with this now.

Did you change the version of either gem? If so, did you run "bundle update" after? That's the only other thing I can think of.