Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LoadError: cannot load such file -- bcrypt_ext on Windows 2008 x64 server

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!

like image 211
user1185081 Avatar asked Nov 07 '15 22:11

user1185081


3 Answers

I spent an entire hour fixing this, just now.

Well what I did was I followed some advice online to do a

gem install bcrypt --platform=ruby

And then, it worked in irb.

irb(main):001:0> require 'bcrypt'
=> true

Later when I had to do a bundle install, for some odd reason rails installed another bcrypt and the error was back. So I had two folders in my gem root.

bcrypt-3.1.10
bcrypt-3.1.10-x64-mingw32

So, since the first folder was the one that got built with the devkit, and it works. I deleted the contents of the second folder and copied the contents of the first into it.

Seems to be working as I'm writing this.

like image 129
devatwork2 Avatar answered Oct 21 '22 07:10

devatwork2


Solution was here: bcrypt-ruby@github:

Rebuild locally the bcrypt gem:

  1. Change to the gem directory \Ruby22-x64\lib\ruby\gems\2.2.0\gems\bcrypt-3.1.10-x64-mingw32\ext\mri>
  2. Run ruby extconf.rb
  3. Run make
  4. Run make install

Note that this works only if your DevKit environment is correctly setup (run devkitvars.bat).

like image 36
user1185081 Avatar answered Oct 21 '22 08:10

user1185081


@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
like image 35
dhrubo_moy Avatar answered Oct 21 '22 07:10

dhrubo_moy