1

I got the gems from https://github.com/mhartl/rails_tutorial_3rd_edition_gemfiles/blob/master/sample_app/Gemfile

then I get an error message like

C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x86-mingw32/li
b/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x
86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x
86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `each'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `block in require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `each'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler.rb:133:in `require'
        from C:/Projects/Mailbox/mailboxer-app/config/application.rb:14:in `<top
 (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `block in server'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `server'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.4
/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
Suriyaa
  • 2,222
  • 2
  • 25
  • 44
me sung
  • 73
  • 1
  • 2
  • 8

3 Answers3

1

This problem is Windows specific which is addressed in bcrypt-ruby issue: 72.

Update you Gemfile as:

gem 'bcrypt-ruby', '3.1.1.rc1', :require => 'bcrypt'

Then

bundle install
RAJ
  • 9,697
  • 1
  • 33
  • 63
1

Just follow the steps of this link: This worked for me https://www.ambidev.com/loaderror-cannot-load-such-file-bcrypt_ext/

You should have DevKit installed and configured correctly to recompile the gem.

LoadError: cannot load such file -- bcrypt_ext

Firt stop your server and remove every bcrypt gem or bcrypt-ruby gem.

C:\>gem uninstall bcrypt
You have requested to uninstall the gem:
    bcrypt-3.1.10-x86-mingw32

bcrypt-ruby-3.1.5 depends on bcrypt (>= 3.1.3)
devise-3.5.2 depends on bcrypt (~> 3.0)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Successfully uninstalled bcrypt-3.1.10-x86-mingw32

Don’t forget to include bcrypt in your Gemfile gem 'bcrypt'

make a bundle update and recompile the gem like this

C:\<Ruby Path>\lib\ruby\gems\bcrypt-3.1.10-x86-mingw32\ext\mri> ruby 
extconf.rb
C:\<Ruby Path>\lib\ruby\gems\bcrypt-3.1.10-x86-mingw32\ext\mri> make
generating bcrypt_ext-i386-mingw32.def
compiling bcrypt_ext.c
compiling crypt.c
compiling crypt_blowfish.c
compiling crypt_gensalt.c
compiling wrapper.c
linking shared-object bcrypt_ext.so

(if make is not recognized as a valid command, execute this command and do a 
make again
C:\<Current Folder> C:\<DevKit Path>\devkitvars.bat
Adding the DevKit to PATH...)

C:\<Ruby Path>\lib\ruby\gems\bcrypt-3.1.10-x86-mingw32\ext\mri> make install
/usr/bin/install -c -m 0755 bcrypt_ext.so /C/<Ruby 
Path>/lib/ruby/site_ruby/2.2.0/i386-msvcrt

Restart your server.

It should do the trick !

Palsri
  • 442
  • 4
  • 13
0

Read the issues #72, #102 and 116 on GitHub!


Update you Gemfile! Add this to your Gemfile:

gem 'bcrypt', '3.1.9'

WATCH OUT!: The bcrypt-ruby gem has changed its name to just bcrypt. Instead of installing bcrypt-ruby, you should install bcrypt. Please update your dependencies accordingly.


Then run the command in your CMD:

bundle

or

bundle install

The bug was repaired in version 3.1.9. Do not use older versions of bcrypt!

Suriyaa
  • 2,222
  • 2
  • 25
  • 44