15

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!

Chloe
  • 25,162
  • 40
  • 190
  • 357
user1185081
  • 1,898
  • 2
  • 21
  • 46
  • Commenting out bcrypt gem works for running the migration, but I need bcrypt for running the rails application. I don't believe it's a bcrypt issue, probably an install issue I don't understand? – user1185081 Nov 08 '15 at 07:17
  • Devise 4.5.0 and BCrypt 3.1.12 fix this. Uninstall all your bcrypts (`gem uninstall bcrypt`) and run `bundle` again. – Chloe Jan 16 '19 at 20:43

9 Answers9

23

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.

Ajay Barot
  • 1,681
  • 1
  • 21
  • 37
devatwork2
  • 231
  • 1
  • 5
  • I ran `bundle install` after installing the 'platform=ruby' bcrypt, and it _didn't_ re-install the '-x64-mingw32' version. Maybe a newer `bundler` recognizes an existing version? Anyway you can just start with `gem remove bcrypt` so you don't have to rename directories. Use `gem list bcrypt --local` to list all your versions. – Chloe Mar 31 '18 at 03:47
12

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).

user1185081
  • 1,898
  • 2
  • 21
  • 46
  • I dont get the make command recognized in my shell :( , installed the devkit and did run devkitvars.bat – damuz91 Mar 03 '17 at 14:22
  • For anyone who don't have the `make` command: add `C:\devkit\mingw\bin` to your PATH. – Ilya Bodrov-Krukowski Apr 30 '17 at 13:04
  • 1
    I added `C:\devkit\mingw\bin` to my PATH, I still couldn't run `make`. For some reason, I had to navigate in `cmd` to `C:\devkit\mingw\bin`, run `devkitvars.bat` and THEN I could run `make`. After I closed the console I lost the ability to `make`. Got the idea from [here.](http://stackoverflow.com/questions/27239491/cannot-install-gem-make-is-not-recognized-as-an-internal-or-external-command-o) – Alex May 09 '17 at 23:14
  • I had to add not only `C:\RailsInstaller\DevKit\mingw\bin` to my PATH, but also `C:\RailsInstaller\DevKit\bin` because `make` and `gcc` (needed to recompile the gem) are located in different folders (?). – prograils Dec 04 '17 at 10:45
  • It compiled 6 files until it failed: `c:/devkit2/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgmp collect2.exe: error: ld returned 1 exit status make: *** [bcrypt_ext.so] Error 1` – Chloe Mar 31 '18 at 03:31
10

@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
dhrubo_moy
  • 1,144
  • 13
  • 31
  • 1
    you made my day, after 10 hours of cleaning up and repearing after migration from rasils 2.3 / 1.9 to raisd 5.0/3.2 an other thig that works again – halfbit Nov 19 '16 at 19:49
  • It compiled 6 files until it failed. `linking shared-object bcrypt_ext.so c:/devkit2/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgmp collect2.exe: error: ld returned 1 exit status make: *** [bcrypt_ext.so] Error 1` – Chloe Mar 31 '18 at 03:35
4

What worked for me on Windows 7:

  1. gem uninstall bcrypt to uninstall all versions of bcrypt, including those listed as dependencies
  2. gem install bcrypt to reinstall
  3. bundle install
Ajay Barot
  • 1,681
  • 1
  • 21
  • 37
1

In my case, a designating of the old version to bcrypt in Gemfile was a cause of the error. I removed a designating of the version and run bundle update bcrypt, then it was settled.

mitsu
  • 383
  • 2
  • 11
1

Here is the solution worked for me:

    C:\> gem uninstall brcypt
    C:\> gem install --no-ri --no-rdoc bcrypt
    C:\> cd (path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri
    C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> ruby extconf.rb
    C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make
    C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make install
Sajidur Rahman
  • 2,764
  • 1
  • 27
  • 26
1

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
0

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

gem 'bcrypt', '~> 3.1.7', platform: :ruby
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
rajanbhadauria
  • 445
  • 4
  • 11
-1

This process is for windows:

The problem is with the programs installed on the system.

Uninstall all rails programs:

  1. All Ruby programs.

  2. RailsInstaller.

Removes all files that have been able to uninstall, you have to do it manually inside:

C:\RailsInstaller

  1. Install de ruby version 2.2 from:

http://railsinstaller.org/en

Wait a moment and it's already to go.

MarlonJon.es

  • Removing all Ruby and Rails executables is a terrible idea. Some people have multiple Ruby versions, multiple Rails versions, and thousands of gems. – Chloe Jan 16 '19 at 19:37