【问题标题】:LoadError in Devise::RegistrationsController#create (cannot load such file -- bcrypt_ext). Why do I get this error?Devise::RegistrationsController#create 中的 LoadError(无法加载此类文件 -- bcrypt_ext)。为什么我会收到此错误?
【发布时间】:2016-02-16 02:11:07
【问题描述】:

我正在使用 ruby​​ 2.2.4。安装 Devise gem 后尝试注册时出现此错误。我以前使用 ruby​​ 2.1.5 时从未遇到过这个错误。是ruby版本导致这里出错的原因吗?

更新:这是我的 gemfile 的样子,我使用的是 Windows 7 Professional 64 位

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]

【问题讨论】:

  • 查看您的 gemfile 并发布您的应用程序正在使用的 bcrypt 版本。让我们知道您使用的是什么操作系统。
  • @MarsAtomic 请看我的更新!

标签: ruby-on-rails devise


【解决方案1】:

Devise 3.5.6 需要 bcrypt

这是我在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

【讨论】:

  • 当我添加 gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt' 并捆绑安装它时,服务器将不再运行。
  • “不会运行”是什么意思?日志中是否包含错误消息?挂了吗?
  • 当我运行 rails server 时,它返回一个很长的错误。但是当我删除 'bcrypt-ruby', '3.1.5', :require => 'bcrypt' 并运行 rails 服务器时,它会运行但问题仍未解决。
  • 当你遇到错误时,你需要说明错误的内容,否则你会期待我的沉默。我没有坐在你旁边——我看不到你的屏幕。在寻求帮助时,您需要学习既完整又具有描述性。如果您收到错误消息,请不要在您知道我要问您错误消息的内容时只说“我收到错误消息”。
  • @MarsAtomic 添加您建议的 gem 后出现此错误C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in require': cannot load such file -- bcrypt_ext (LoadError)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多