Setting up Bcrypt for Rails on Windows

You probably end up here because you are looking for a way to install bcrypt in your Windows machine. I needed bcrypt for authentication in my Rails application, I struggled a little bit trying to get it working on rails latest version. You might have a similar error on your console like the one bellow:

C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activesupport-4.0.0/lib/active_support/depen dencies.rb:228:in require: 126: The specified module could not be found. – C :/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-ruby-3.1.11-x64-mingw32/lib/bcrypt_ext.so (LoadError)

Let’s fix that.

Note: This tutorials is using gems 2.3.0 at the time it was created, which might be different from the current version that you are using. You can simply change ALL “2.3.0” on the commands I used for this tutorial to the version you are currently using.

  1. Make sure you have the latest version of Ruby installed on your computer. You can download Ruby for Windows from this link: http://rubyinstaller.org/downloads/
  2. Next is you need to navigate to your rails application then open up your Gemfile and uncomment  gem ‘bcrypt’
  3. Then run bundle install from your terminal to install the bcrypt dependecy.
  4. If you are currently utilizing bcrypt in your application, when you run using rails server you will get an error similar to the error code bellow:
    • C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activesupport-4.0.0/lib/active_support/depen dencies.rb:228:in `require’: 126: The specified module could not be found. – C :/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-ruby-3.1.11-x64-mingw32/lib/bcrypt_ext.so (LoadError)
  5. CD to your gem directory:  C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11-x64-mingw32\ext\mri
  6. Run ruby extconf.rb
  7. Run make
  8. Run make install 
    • This command will generate bcrypt_ext.so
  9. Copy the generated file “bcrypt_ext.so” to C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11-x64-mingw32\lib\2.3
    • If the folder “2.3” (or whatever version you are using)  is not present, simply create it then paste the file “bcrypt_ext.so” in it.
  10. Restart rails, you will see that the bcrypt_ext.so (LoadError) message is gone.
  11. Congratulations, you just have configured bcrypt in your Windows machine.

If you are experiencing problems with the command: make being unrecognized in your terminal –  it means you do not have DevKit installed in your Windows machine. You can follow the tutorial bellow to install DevKit and associate it with your Ruby installation.

  1. Download DevKit from here: http://rubyinstaller.org/downloads/
  2. Extract the contents of DevKit, preferably under “C:/RubyDevKit”
  3. cd C:\RubyDevKit
  4. ruby dk.rb init
  5. ruby dk.rb install
  6. devkitvars.bat



Do you need help with a project? or have a new project in mind that you need help with?

Contact Me