在replace_gem中的块无法激活bcrypt-ruby(〜> 3.0.0),已经激活了bcrypt-ruby-3.1.1

时间:2013-07-22 05:44:17

标签: bundle bcrypt bcrypt-ruby

我已经看了几个关于这个问题的答案,似乎没有人能做到这一点。这是在Windows上,我迷失了想法。谢谢你的帮助!

C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.1-x86-mingw32/lib/bcrypt_ext.rb:2:in require': cannot load such fil e -- 2.0/bcrypt_ext (LoadError) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.1-x86-mingw32/lib/bcrypt_ext.rb:2:in'

    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.1-x86-mingw32/lib/bcrypt.rb:12:in `require'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.1-x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require

”         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in块in require'         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in require'         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in require' from C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/config/application.rb:12:in'         来自C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/config/environment.rb:2:in require' from C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/config/environment.rb:2:in'         来自C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/spec/spec_helper.rb:3:in require' from C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/spec/spec_helper.rb:3:in'         来自C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/spec/models/user_spec.rb:1:in require' from C:/Users/Natecraft/Documents/railstut/Nate_Enddy_d3/blog/spec/models/user_spec.rb:1:in'         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:在load' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in块中加载 _spec_files'         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in load_spec_fil ES'         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/command_line.rb:22:in run' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/runner.rb:80:in run'         来自C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.3/lib/rspec/core/runner.rb:17:在`block in autorun'

1 个答案:

答案 0 :(得分:1)

我刚刚在我的项目中解决了同样的问题。

问题是在版本3.1.1中不支持方法'has_secure_password',因此在版本3.1.1中在模型中调用它将不起作用。 但是,正如这里提到的 - &gt; bcrypt error: Devise ruby 2.0 and rails 4.0,只是在gemfile中指定一个版本将不起作用,因为将使用与Windows兼容的版本,这会导致它自己的问题。

我的解决方案是分叉bcrypt-ruby的github repo,然后将其回滚到3.0.1版本并将其用作gem的源代码,如下所示:

gem 'bcrypt-ruby', git: 'git@github.com:hananamar/bcrypt-ruby.git', :require => 'bcrypt'

你被邀请使用我的回购:)

希望这些问题很快得到修复。