我无法找到解决此问题的方法,并且尝试了许多其他人遇到的修复,但均未成功。我正在研究 Michael Hartl 的 Ruby on Rails 5 教程,它需要使用 bcrypt 来实现该has_secure_password
功能。当我运行测试时,我收到一条很长的错误消息,开头为:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in 'require': cannot load such file -- bcrypt_ext (LoadError)
我尝试卸载并重新安装 bcrypt,并--platform=ruby
在最后添加并在 gemfile 中包含各种版本;gem 'bcrypt', '~> 3.1.7'
, 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw]
,'bcrypt', '~> 3.1.7', platforms: [:ruby]
包括从命令行安装 gem 文件的各种组合。从控制台安装时保留 gemfile 散列,仅使用 gemfile 链接卸载和运行捆绑安装。
这是我在尝试访问 Rails 控制台时收到的完整错误消息:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in 'require': cannot load such file -- bcrypt_ext (LoadError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `block (2 levels) in require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `each'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `block in require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `each'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler.rb:114:in `require'
from C:/Users/Bill/Documents/Sites/sample_app/config/application.rb:7:in `<top (required)>'
from C:/Ruby23x64/lib/ruby/gems/2.3.0/gems/railties-.1.4/lib/rails/command/actions.rb:15:in `require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:96:in `perform'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in`run'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我正在使用 Ruby 2.3.3 版和在 Windows 7x64 上运行的 Rails 5.1.4 版。
在这一点上任何人都可以提供给我的任何见解将不胜感激。
更新
因此,经过无数小时尝试解决问题后,使用 gemfile:
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
是什么为我解决了这个问题。这可能不是一个永久的解决方案,但至少它让我继续前进!