bcrypt() is a sophisticated and secure hash algorithm designed by The OpenBSD project for hashing passwords. The bcrypt Ruby gem provides a simple wrapper for safely handling passwords.
However, sometimes the rails application would fail to start after installing the bcrypt gem on Windows. The error would look similar to below.
The issue is that it fails to load the bcrypt_ext which is the native built extension, the reason may be the library is wrongly built. To fix this issue, below steps can be followed.
- Open a command console
- cd to the gem directory C:\RailsInstaller\Ruby2.2.0\lib\ruby\gems\2.2.0\gems\bcrypt-3.1.10-x86-mingw32\ext\mri
- Run ruby extconf.rb. It should create the Makefile
- Run make. It will build the extension libraries.
- Run make install
The whole process looks like
Now if you start your application, you should see the issue is gone.
Getting this error:
C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11-x86-mingw32\ext\mri>ruby extconf.rb
creating Makefile
C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11-x86-mingw32\ext\mri>make
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/make-0.3.1/bin/make:4:in `<top (required)>': undefined local variable or method `make' for main:Object (NameError)
from C:/RailsInstaller/Ruby2.3.0/bin/make:22:in `load'
from C:/RailsInstaller/Ruby2.3.0/bin/make:22:in `<main>'