2017-08-07 86 views
-1

我在Windows 7 64位,我运行Ruby 2.3.3和Rails 5.1.2。Rails错误 - “无法加载这样的文件 - bcrypt_ext”在Windows 7,64

"LoadError in Devise::RegistrationsController#create" "cannot load such file -- bcrypt_ext"

我已经通过谷歌搜索遇到类似这种的解决方案:我试图在我的网站上创建一个新用户时碰到这个错误来跟我回报率的项目

"Firstly uninstall bcrypt and bcrypt-ruby by running these two commands: gem uninstall bcrypt and gem uninstall bcrypt-ruby Install it again with gem install bcrypt --platform=ruby In your Gemfile write gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt' Run bundle install"

然而,当我试图在我的控制台运行gem uninstall bcrypt我收到此错误信息:

"$ gem uninstall bcrypt ERROR: While executing gem ... (Gem::DependencyRemovalException) Uninstallation aborted due to dependent gem(s)"

我相信这是因为我设计的宝石。当我在控制台运行gem list bcrypt我收到这样的输出:

"bcrypt (3.1.11 x86-mingw32)"

My rails app came with this line commented out in my gem file:

"# Use ActiveModel has_secure_password

gem 'bcrypt', '~> 3.1.11'"

我试图在取消它放回代码,当我这样做的Rails服务器加载失败,并列出了此错误控制台:

C:\Users\James\Desktop\rails_app>rails s 
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.3/lib/act 
ive_support/dependencies.rb:292:in `require': cannot load such file -- bcrypt_ex 
t (LoadError) 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport- 
5.1.3/lib/active_support/dependencies.rb:292:in `block in require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport- 
5.1.3/lib/active_support/dependencies.rb:258:in `load_dependency' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport- 
5.1.3/lib/active_support/dependencies.rb:292:in `require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11- 
x86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11- 
x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler/runtime.rb:82:in `require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler/runtime.rb:82:in `block (2 levels) in require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler/runtime.rb:77:in `each' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler/runtime.rb:77:in `block in require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler/runtime.rb:66:in `each' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler/runtime.rb:66:in `require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.2 
/lib/bundler.rb:108:in `require' 
     from C:/Users/James/Desktop/rails_app/config/application.rb:7:in `<top (
required)>' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/commands/server/server_command.rb:129:in `require' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/commands/server/server_command.rb:129:in `block in perform' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/commands/server/server_command.rb:126:in `tap' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/commands/server/server_command.rb:126:in `perform' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/li 
b/thor/command.rb:27:in `run' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/li 
b/thor/invocation.rb:126:in `invoke_command' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/li 
b/thor.rb:369:in `dispatch' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/command/base.rb:63:in `perform' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/command.rb:44:in `invoke' 
     from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.3 
/lib/rails/commands.rb:16:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

在这一点上,我没有想法。请指教。谢谢。

回答

0

在卸载bcrypt之前,您应该卸载bcrypt-ruby,因为这是相关的gem。

这可以为这样做:

gem uninstall bcrypt-ruby 
gem uninstall bcrypt 
gem install bcrypt --platform=ruby 
+0

谢谢你的回应。该解决方案对我无效。我仍然在试图卸载gem时在控制台中收到此错误: 错误:执行gem时(Gem :: DependencyRemovalException) 卸载由于依赖gem(s)而中止 我仍然认为这是由于到设计宝石,但我很想考虑其他选择/意见。 – James

0

尝试这为我工作的步骤如下:

  1. 删除您brypt的Gemfile
  2. 输入以下信息相关的任何东西到您的Gemfile

gem'bcrypt',git:'https://github.com/codahale/bcrypt-ruby.git”:需要=> 'bcrypt'

  • 运行 '安装捆绑' 在你的项目的根目录,它应该工作。
  • 由于某种原因,当你把它指向它为我工作的git页面。

    相关问题