LoadError: cannot load such file — bcrypt_ext on W

2019-02-06 04:17发布

I upgraded my environment from Ruby 2.0.0 to 2.2.3.

I also upgraded (overwrite) DevKit, and re-run ruby dk.rb install.

I removed Gemfile.lock and ran bundle install to start with a brand new environment. Everything looks ok, but I get the error:

E:\Projects\development\Stairs>rake db:migrate 
rake aborted!
LoadError: cannot load such file -- bcrypt_ext
E:/Projects/development/Stairs/config/application.rb:7:in `<top (required)>'
E:/Projects/development/Stairs/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- 2.2/bcrypt_ext
E:/Projects/development/Stairs/config/application.rb:7:in `<top (required)>'
E:/Projects/development/Stairs/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

I first had the same issue with Nokogiri, which I solved using this solution : Nokogiri load error using Juloi Elixir's solution and installing Nokogiri from a local copy.

But I don't feel like doing this foreach gem! It looks like ruby is searching the gem using a ./ or ./2.2 path, while gems are stored in a ./2.2.0 path. Is this configurable? How can I solve this issue?

Note: Gemfile contains gem 'bcrypt', '~> 3.1.10'

Thanks!

9条回答
▲ chillily
2楼-- · 2019-02-06 05:06

This works for me, add this to your gems file:

gem 'bcrypt', '~> 3.1.7', platform: :ruby
查看更多
叛逆
3楼-- · 2019-02-06 05:12

@user1185081 's solution worked for me in a windows machine. I ran following commands and worked like magic:

$ cd C:\RailsInstaller\Ruby2.2.0\lib\ruby\gems\2.2.0\gems\bcrypt-3.1.10-x86-mingw32\ext\mri  
$ ruby extconf.rb
$ C:\<DevKit Path>\devkitvars.bat  (assuming you have devkit installed)(Ran this instead of running "make" because it was not recognized as an internal or external command)
$ make install
查看更多
太酷不给撩
4楼-- · 2019-02-06 05:18

I had the same problem:

cannot load such file — bcrypt_ext


Windows 8.1 64bit

ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

Rails 5.1.4


My solution:

  1. gem uninstall bcrypt-ruby
  2. gem uninstall bcrypt
  3. gem install bcrypt –platform=ruby
  4. added this whole line to Gemfile:

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

  1. bundle install
查看更多
登录 后发表回答