6

Trying to run ruby on my Windows 7 machine whenever i go to rails s or rake db:migrate i get the following error Cannot load such file bcrypt_ext.

My ruby version is 2.2.1 my rails version is 4.2.0 and the bcrypt version is 3.1.10. All the gems install correctly when i run bundle install however whenever i try to rake it gives me that error. Any help would be greatly appreciated

Byrd
  • 867
  • 3
  • 12
  • 24
  • Try with `ruby-bcrypt` version `3.1.9` ; this [thread on github](https://github.com/codahale/bcrypt-ruby/issues/102) seems to imply that the bug was fixed for that specific version. Maybe `3.1.10` has a regression. – Prakash Murthy Mar 27 '15 at 04:33

6 Answers6

16

You need to use what it says here: https://www.alib.jp/entries/bcrypt_ext_load_error_on_ruby21x

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
Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • 3
    This is bizarre. I used this answer, but then `make install` put the resulting `.so` file in `C:\Ruby22\lib\ruby\site_ruby\2.2.0\i386-msvcrt`. The gem was not looking there for it, according the error message. So, I copied that manually to `C:\Ruby22\lib\ruby\gems\2.2.0\gems\bcrypt-ruby-3.1.1.rc1-x86-mingw32\lib` and it worked fine. Different version of gem, as you can see, but maybe it will help the downvoter. – Hut8 Jan 07 '16 at 01:38
  • 1
    On windows platform, this can download DevKit-mingw64 on ruby installer can devkitvars.bat. for making gcc build – AlexLeung Feb 11 '16 at 08:02
  • 1
    I don't understand this solution except for the gem install part. How do I know what is my path to gems root? – Jeramae Bohol Feb 16 '16 at 12:49
  • It's in `c:/ruby_dir/lib/ruby/gems/[[ver]]/gems` – Richard Peck Feb 16 '16 at 12:52
  • It is saying ` make: command not found what's make command, how do I let cmd know what make is ` – Sanjeev Feb 22 '17 at 19:42
  • You need to get `make.exe` which is either from `mingw` or `devkit` - if that makes sense I can explain it more specifically :) – Richard Peck Feb 22 '17 at 19:59
5

I meet the same problem in Window 8.1 64bit , Ruby 2.3.3 64bit , Rails 4.2.10.

My quick solution :

Step 1 : Remove all bcrypt in gem : gem uninstall bcrypt ( choose option 3 if existed (remove all))

Step 2 : Install bcrypt again : gem install bcrypt

Then check version of bcrypt : gem list bcrypt

Step 3 : In Gemfile of your project, add : gem 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw] notice : change the suitable version of your bcrypt (my version : 3.1.11)

Step 4 : Run command in the path of your project : bundle install

Step 5 : Remove the unneeded bcrypt : Run command : gem uninstall bcrypt You can see some version of bcrypt , you should keep one version : bcrypt-[your-version] . (Remove all version : bcrypt-[your-version]-x64-mingw32 . In mycase , remove : bcrypt-3.1.11-x64-mingw32)

Restart Rails sever , done

I think this proplem because when we install bcrypt , we didn't specify 64bit or 32bit , it is not compatible with window or ruby ( 64bit or 32bit )

Phi Ưng
  • 51
  • 1
  • 2
4

For Windows 10, bcrypt 3.1.11 now works, checked in 24144

steps:

  1. shut down all rails servers
  2. uninstall all versions of bcrypt
  3. manually install v3.1.1 (gem install bcrypt -v '3.1.11')
  4. update gem files of projects

current versions

  • ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

  • OS Name: Microsoft Windows 10 Pro

  • OS Version: 10.0.10586 N/A Build 10586

Mark Filley
  • 163
  • 2
  • 2
  • 8
  • When you install bcrypt, use this command: `gem install bcrypt --platform=ruby` this has worked for me a number of times. – Tensigh Apr 05 '18 at 05:24
4

The dirty quick workaround is to install the mri version with

gem install bcrypt --platform=ruby

worked for me.

Fetching: bcrypt-3.1.11.gem (100%) Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed bcrypt-3.1.11

source: topac commented on Apr 17, 2015 https://github.com/codahale/bcrypt-ruby/issues/116

Ozan Yurtseven
  • 810
  • 8
  • 17
1

Rich Peck solution worked for me with a small update. Make sure the devkit is included in the environment path.(Check it by typing path in the command prompt) If its not included,you need to add the devkit/bin and devkit/mingw/bin paths to your PATH var.

Otherwise - make: x86_64-w64-mingw32-gcc: Command not found - error will be thrown while you make the file.

Once the error is fixed, then i am able to make the file and the bcrypt_ext issue is solved.

Community
  • 1
  • 1
maniempire
  • 791
  • 11
  • 12
0

Most likely the compiled gem binaries don't contain binaries for Ruby 2.2.1. This is because there is a problem with cross-compiling Ruby with a Windows target. See this answer for more details.

The best alternative is to downgrade to Ruby 2.1.5.

You can try to compile the gem yourself, but that's a totally different beast. In some cases, like nokogiri, it's not even possible.

Community
  • 1
  • 1
Azolo
  • 4,353
  • 1
  • 23
  • 31
  • Thanks for the tip, getting an ssl cert problem when trying to install gems so i got to go from there. – Byrd Mar 27 '15 at 17:01
  • That's a completely different issue. [Here is the fix](https://gist.github.com/luislavena/f064211759ee0f806c88#installing-using-update-packages-new) – Azolo Mar 27 '15 at 23:43
  • Thanks for the guide, but seems like alot of the gems in this bundle might not be compatible with windows. getting the same error now on pg_ext – Byrd Mar 28 '15 at 03:32
  • The `pg` gem should work. People work really hard on getting things to work for Windows users, but things aren't always perfect. Which version of the `pg` gem are you using? If it's [version `0.17.x` try upgrading to `0.18.1`](http://stackoverflow.com/questions/26617779/pg-pg-ext-load-error-in-rails). – Azolo Mar 28 '15 at 05:41
  • Yeah problems do a occur. as per your advice i was running on 0.17.x upgaded to 0.18.1 no luck. – Byrd Mar 28 '15 at 15:32
  • how do I downgrade to ruby 2.1.5? – Jeramae Bohol Feb 16 '16 at 12:34