Setting up Bcrypt for Rails on Windows
Date Posted: October 11, 2016, 11:03 am
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:
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)</span></em>
Let's fix that.
<strong>Note</strong>: 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.
<li>Make sure you have the latest version of Ruby installed on your computer. You can download Ruby for Windows from this link: <a href="http://rubyinstaller.org/downloads/">http://rubyinstaller.org/downloads/</a></li>
<li>Next is you need to navigate to your rails application then open up your Gemfile and uncomment <strong>gem 'bcrypt'</strong></li>
<li>Then run <strong>bundle install</strong> from your terminal to install the bcrypt dependecy.</li>
<li>If you are currently utilizing bcrypt in your application, when you run using <strong>rails server </strong>you will get an error similar to the error code bellow:
<li><span style="color: #800000;"><em>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)
- This command will generate bcrypt_ext.so
- 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.
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.
- Download DevKit from here: http://rubyinstaller.org/downloads/
- Extract the contents of DevKit, preferably under “C:/RubyDevKit”
- cd C:\RubyDevKit
- ruby dk.rb init
- ruby dk.rb install
- This command will register all DeKit variables to your Windows environment variables path.