LoadError in Devise::RegistrationsController#create (cannot load such file — bcrypt_ext). Why do I get this error?

点点圈 提交于 2020-01-17 06:16:06

问题


I'm using ruby 2.2.4. I get this error when I tried to sign up after installing the Devise gem. I never experienced this error when I used to use ruby 2.1.5. Is the ruby version the cause of the error here?

UPDATE: this is what my gemfile looks like and I'm using Windows 7 Professional 64-bit

source 'https://rubygems.org'


gem 'rails', '4.2.5.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'simple_form', '~> 3.2', '>= 3.2.1'
gem 'country_select', '~> 2.5', '>= 2.5.1'
gem 'devise', '~> 3.5', '>= 3.5.6'

group :doc do
    gem 'sdoc', '~> 0.4.0'
end


group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

回答1:


Devise 3.5.6 needs bcrypt <= 3.0, which you probably have, but some versions of bcrypt were not supported with specific versions of Ruby on Windows, which is probably what you're seeing.

This is what I dug up on the bcrypt github repo:

1) Launch a terminal session
2) Enter gem uninstall bcrypt
3) Enter gem uninstall bcrypt-ruby
4) Enter gem install bcrypt --platform=ruby
5) Edit your gemfile to include the following line:
   gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt'
6) Run bundle install


来源:https://stackoverflow.com/questions/35422463/loaderror-in-deviseregistrationscontrollercreate-cannot-load-such-file-bc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!