Unable to activate bcrypt-ruby (~> 3.0.0), already

2019-08-30 13:30发布

问题:

This question already has an answer here:

  • can't activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.1. Make sure all dependencies are added to Gemfile 9 answers

I'm trying to install bcrypt to handle passwords.

I ran gem install bcrypt-ruby and got:

....Successfully installed bcrypt-ruby-3.1.2

I added gem "bcrypt-ruby", "~> 3.1.2" and ran bundle install, and restarted the server which ran the program but I got the error:

get Gem::LoadError in UsersController#new 
can't activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.2. Make sure all dependencies are added to Gemfile.


format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
**has_secure_password** <---Error
validates :password, length: { minimum: 6 }
end

回答1:

The ~> 3.0.0 version conflicts with ~> 3.1.2 one, because comparison takes place 3.0.~ to 3.1.~, and failed. You shave to change ~> 3.0.0 to ~> 3.0, in order to compare 3.~ to 3.1.

If you are unable to do it, you have to see into Gemfile.lock, which gem require 3.1.2 version of bcrypt-ruby in, and try to downdrade it.



回答2:

You could change the Gemfile line to...

gem 'bcrypt-ruby', '~> 3.0.0'

and then bundle and that should fix it!



回答3:

Try

bundle update

I would also recommend simply putting gem "bcrypt-ruby", "3.1.2" in the Gemfile.