bcrypt loading error in windows 10

前提是你 提交于 2019-12-01 10:09:42

问题


now I am trying to install bcrypt in windows 10, but I got an loading error whenever running webrick server as the following.

C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bcrypt-3.1.10-x64-mingw32/lib/bcrypt.rb:16:in 
`require': cannot load such file -- bcrypt_ext (LoadError)

I am using rails 4.1.5 and ruby 2.2.3. There was no problem with bcrypt when I was using windows 8.1. The ruby version was 2.1.6 when I was using windows 8.1

How can I solve this bcrypt issue?


回答1:


It took me few hours to get this done but please feel free to share it.The root problem here is that ruby itself comes with bcrypt version 3.1.5 which is having bugs with the newer updates. However when you install or uninstall the bcrypt you are leving behind bcrypt-ruby which it always asks for first and hence all what you are doing won't go through so what to do ? 1- uninstall bcrypt and bcrypt-ruby by running these two commands: gem uninstall bcrypt and

 gem uninstall bcrypt-ruby

2- Install it again with

gem install bcrypt --platform=ruby 

In your Gemfile write

 gem 'bcrypt','~>3.1.11' 

NOW as i write these lines the latest version is 3.1.11 but whatever version is updated just add it from their gem page. Run bundle install and it should work just fine.




回答2:


In your gem file add:

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

This worked for me on Windows 10 64 Bit.




回答3:


Try fix Gemfile

gem 'bcrypt', '~> 3.1.10', require: false
if Bundler::WINDOWS
  gem 'bcrypt-ruby', '~> 3.0.0', require: false
else
  gem 'bcrypt', '~> 3.1.10', require: false
end



回答4:


gem uninstall bcrypt and gem install bcrypt --platform=ruby was a temporary fix, broke after bundle install.

My Fix =>

gemfile.lock:

(Delete bcrypt from gemfile.lock)

Change devise to:

devise (4.4.3)
  bcrypt (~> 3.0)

< scroll down to DEPENDENCIES >

DEPENDENCIES

  bcrypt!

  devise (~> 4.3)

Gemfile:

gem 'devise', '~> 4.3'

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

To commandline: gem uninstall bcrypt bundle install



来源:https://stackoverflow.com/questions/34469246/bcrypt-loading-error-in-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!