我从https://github.com/mhartl/rails_tutorial_3rd_edition_gemfiles/blob/master/sample_app/Gemfile
获得了宝石然后我收到类似
的错误消息C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x86-mingw32/li
b/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x
86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x
86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler.rb:133:in `require'
from C:/Projects/Mailbox/mailboxer-app/config/application.rb:14:in `<top
(required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `tap'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `server'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
答案 0 :(得分:1)
此问题是特定于Windows的问题,已在bcrypt-ruby issue: 72中解决。
将Gemfile
更新为:
gem 'bcrypt-ruby', '3.1.1.rc1', :require => 'bcrypt'
然后
bundle install
答案 1 :(得分:1)
只需按照此链接的步骤操作: 这对我有用 https://www.ambidev.com/loaderror-cannot-load-such-file-bcrypt_ext/
您应该正确安装和配置DevKit以重新编译gem。
LoadError: cannot load such file -- bcrypt_ext
彻底停止服务器并删除每个bcrypt gem或bcrypt-ruby gem。
C:\>gem uninstall bcrypt
You have requested to uninstall the gem:
bcrypt-3.1.10-x86-mingw32
bcrypt-ruby-3.1.5 depends on bcrypt (>= 3.1.3)
devise-3.5.2 depends on bcrypt (~> 3.0)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Successfully uninstalled bcrypt-3.1.10-x86-mingw32
不要忘记在您的Gemfile中包含bcrypt 宝石'bcrypt'
进行捆绑更新并像这样重新编译gem
C:\<Ruby Path>\lib\ruby\gems\bcrypt-3.1.10-x86-mingw32\ext\mri> ruby
extconf.rb
C:\<Ruby Path>\lib\ruby\gems\bcrypt-3.1.10-x86-mingw32\ext\mri> make
generating bcrypt_ext-i386-mingw32.def
compiling bcrypt_ext.c
compiling crypt.c
compiling crypt_blowfish.c
compiling crypt_gensalt.c
compiling wrapper.c
linking shared-object bcrypt_ext.so
(if make is not recognized as a valid command, execute this command and do a
make again
C:\<Current Folder> C:\<DevKit Path>\devkitvars.bat
Adding the DevKit to PATH...)
C:\<Ruby Path>\lib\ruby\gems\bcrypt-3.1.10-x86-mingw32\ext\mri> make install
/usr/bin/install -c -m 0755 bcrypt_ext.so /C/<Ruby
Path>/lib/ruby/site_ruby/2.2.0/i386-msvcrt
重新启动服务器。
它应该做的伎俩!
答案 2 :(得分:0)
更新 with open(file_A, 'r') as f1:
read_A = f1.read()
with open(file_B, 'r') as f2:
read_B = f2.read()
!将其添加到 Gemfile
:
Gemfile
观看!:
gem 'bcrypt', '3.1.9'
gem已将其名称更改为bcrypt-ruby
。而不是 安装bcrypt
,您应该安装bcrypt-ruby
。请更新你的 相应的依赖。
然后在CMD中运行命令:
bcrypt
或
bundle
该错误已在3.1.9版本中修复。不要使用旧版本的bcrypt!