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

后端 未结 9 2003
不知归路
不知归路 2020-12-03 05:13

I have Rails 4.0.0 app. When I run bundle install command there is no problem. This is my GemFile.

source \'https://rubygems.org\'

# Bundle edge Rails inste         


        
相关标签:
9条回答
  • 2020-12-03 05:47

    In console:

    $ gem install bundler
    $ gem install bcrypt
    $ bundle update bcrypt
    
    0 讨论(0)
  • 2020-12-03 05:55
    1. Install both 3.0.1 and 3.1.2 bcrypt version
    2. go to "\Ruby200\lib\ruby\gems\2.0.0\gems\bcrypt-ruby-3.1.2-x86-mingw32\lib"
    3. copy the '2.0' folder
    4. paste into "Ruby200\lib\ruby\gems\2.0.0\gems\bcrypt-ruby-3.0.1-x86-mingw32\lib"
    5. include gem 'bcrypt-ruby' in your Gemfile
    6. bundle install
    0 讨论(0)
  • 2020-12-03 05:59

    Remove Gemfile.lock and specify the gem 'bcrypt-ruby', '3.0.0'. Run bundle install. Actually, in local gem file bcrypt-ruby should be uninstalled.

    0 讨论(0)
  • 2020-12-03 06:05

    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. Here's the commit if you're curious.

    0 讨论(0)
  • 2020-12-03 06:08

    I had the same issue, but the current approach provided gem 'bcrypt-ruby', '~> 3.0.0' didn't work so I actually installed version 3.0.0 adding the line gem 'bcrypt-ruby', '3.0.0' to Gemfile and installing specific version 3.0.0 (although it should work up to version 3.0.9)

    gem install --version='3.0.0' bcrypt-ruby

    After this, just verify your bundle install, you can run bundle show bcrypt-ruby and then you should have the path where this gem was installed, something like

    %RUBY_PATH%/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.0

    after these steps I was able to use the bcrypt without problems... just posting this in the event someone still encounters this issue.

    0 讨论(0)
  • 2020-12-03 06:08

    Use ActiveModel has_secure_password

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

    Had the same issue. Removing the comment # from above line resolved my issue, as jconley mentioned.

    0 讨论(0)
提交回复
热议问题