0
votes

My app loads locally but any interaction throws an error:

Started GET "/users/sign_in" for 127.0.0.1 at 2016-11-22 15:42:14 +1100
  ActiveRecord::SchemaMigration Load (1.0ms)  SELECT "schema_migrations".* FROM
"schema_migrations"
Processing by Users::SessionsController#new as HTML
  Rendering users/sessions/new.html.erb within layouts/application
  Rendered users/sessions/new.html.erb within layouts/application (37.0ms)
  Rendered layouts/_navbar.html.erb (1.0ms)
Completed 200 OK in 1007ms (Views: 978.5ms | ActiveRecord: 4.0ms)


Started POST "/users/sign_in" for 127.0.0.1 at 2016-11-22 15:42:29 +1100   
Completed 401 Unauthorized in 8ms (ActiveRecord: 1.0ms)


Processing by Users::SessionsController#new as HTML
  Parameters: {"utf8"=>"V", 
Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.0ms)


LoadError (cannot load such file -- bcrypt):

app/controllers/users/sessions_controller.rb:6:in `new'
  Rendering C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/action

I am running Windows7 64bit, Ruby23-x64, Rails 5.0.0.1 and the only bcrypt gem I have installed is: bcrypt-3.1.11.

I attempted the solution here: cannot load such file -- 1.9/bcrypt_ext (LoadError) but bcrypt-ruby no longer exists with newer versions of ruby.

Edit: If I run gem install bcrypt, I get an additional bcrypt gem in: C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems. I now have 2 bcrypts:

  • C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11
  • C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11-x64-mingw32

Which one do I keep, and what do I need to change in my Gemfile?

What am I missing?

1
Is the bcrypt gem correctly installed? - Ed de Almeida
try adding the gem file like, gem 'bcrypt-ruby', '3.1.1.rc1', :require => 'bcrypt' - Sravan
try the next version of bcrypt, 3.1.2 - Sravan
@Sravan 3.1.2 is actually older, I am using 3.1.11 which I can see is the newest: rubygems.org/gems/bcrypt/versions as of today. - rlsaj
@EddeAlmeida within my directory: C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems I have: bcrypt-3.1.11 so I believe so. How else can I test that it's installed correctly? - rlsaj

1 Answers

10
votes

You put this gem 'bcrypt' into your Gemfile.

If you put it and ran bundle install, did you restart your rails server ?

If you still had this problem, you can do this as follow:

  • Firstly uninstall bcrypt and bcrypt-ruby by running these two commands:

    gem uninstall bcrypt and gem uninstall bcrypt-ruby

  • Install it again with gem install bcrypt --platform=ruby

  • In your Gemfile write gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt'

  • Then run bundle install and restart your rail server