13

I keep getting this error when i try to run my app:

C:/ruby-2.0.0-p195-i386-mingw32/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0.rc1 /lib/active_support/dependencies.rb:228:in `require': cannot load such file -- 2 .0/bcrypt_ext (LoadError)

Any takers? - im trying to use the devise gem for basic user authentication..

Mulaiko
  • 536
  • 7
  • 23

6 Answers6

26

I've gotten this error when I updated to Ruby 2.0.0+ on Windows. I was able to solve it by uninstalling all versions of bcrypt that were downloaded, and building the gem using DevKit.

gem uninstall bcrypt-ruby

gem install bcrypt-ruby --platform=ruby --no-ri --no-rdoc

Usually doing a bundle update will download a precompiled gem mingw32 extension, which in this case appears not to work. This workaround for reinstalling bcrypt-ruby will hopefully not be needed in the future.

Additionally, I keep updated Windows installation instructions for Ruby on Rails here (mostly for my own reference) for installing Ruby on Rails on Windows.

https://github.com/remomueller/documentation/tree/master/windows

Some other Windows pitfalls you may run into are also listed there:

https://github.com/remomueller/documentation/blob/master/windows/190-miscellaneous.md

remo
  • 498
  • 5
  • 8
  • 3
    This works however it will get overriden when you do a `bundle install`. I solved it by installing it from github. – mihai Jul 01 '13 at 14:36
  • Thanks Remo, I had to bundle install, then remove the bcrypt gem and install as per your instructions. – Matt Jul 22 '13 at 09:42
  • 1
    sometimes it is necessary to get bcrypt-ruby-3.0.1 - just execute `gem install bcrypt-ruby -v 3.0.1 --platform=ruby --no-ri --no-rdoc` – Gobol Sep 08 '13 at 21:33
  • BTW: it is sufficient to `gem uninstall bcrypt-ruby` and select **-x86-mingw32** version to uninstall. – Gobol Nov 10 '13 at 19:13
  • 2
    It still works only `bcrypt-ruby` changed its name to `bcrypt`. I'm so happy it still works. – gneri Aug 23 '15 at 00:13
  • It's taken me a week to solve this bcrypt problem by just following this. I did uninstall, reinstalled again, but I had gem bcrypt 3.1.17 added in the gemfile before doing the above process (@remos process). I didn't run bundle install. – blakroku Jul 03 '17 at 18:35
9

Until this problem is fixed, the best workaround is to install bcrypt-ruby from git:

gem 'bcrypt-ruby', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'

Update (June 2016.) - as @gneri mentioned, bcrypt-ruby changed it's name to bcrypt, so use:

gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
Community
  • 1
  • 1
mihai
  • 37,072
  • 9
  • 60
  • 86
2

On problem with has_secure_password on Window 7 helps this

gem uninstall bcrypt-ruby

gem uninstall bcrypt

gem install bcrypt-ruby --platform=ruby --no-ri --no-rdoc

gem install bcrypt --platform=ruby --no-ri --no-rdoc

Add to Gemfile:

gem 'bcrypt-ruby', '~> 3.0.0', :require => 'bcrypt'
gem 'bcrypt'

bundle install

0

turns out that it was a problem with the version of ruby that i was using. I was using ruby 2 (32bit).

but if you switch to the 64bit version of ruby 2 the error goes away.

Mulaiko
  • 536
  • 7
  • 23
0

Seems like the downfall of using windows as a development platform for ROR apps. I need to use Ruby 2.0 32 bit in order to get PG gem for a postgresql connection to work or I have to use Ruby 2.0 64 bit to get 'Devise' gem to work.

  • I never had that problem; I've used Rails 4 as early as the first beta and never had to switch between 32-bit/64-bit of Ruby on Windows for either gem to work... – Kevin_L22 Oct 01 '13 at 16:13
  • And it happens on Ubuntu, as well :\ – Jaime Apr 23 '14 at 04:20
0

The new version of bundler just came out. It nows about x64 gems

gem install bundler -v '1.4.0.pre.2'
Dmitriy
  • 341
  • 2
  • 13