Reputation: 135
I am having trouble finding a solution to this issue, and have tried many fixes others have ran into with no success. I am working on the Ruby on Rails 5 Tutorial by Michael Hartl which requires using bcrypt to implement the has_secure_password
feature. When I run the test I get a long error message which starts with:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in 'require': cannot load such file -- bcrypt_ext (LoadError)
I have attempted uninstalling and reinstalling bcrypt with adding --platform=ruby
at the end and including various versions in the gemfile; gem 'bcrypt', '~> 3.1.7'
, 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw]
, 'bcrypt', '~> 3.1.7', platforms: [:ruby]
including various combinations of installing the gem file from the command line. Leaving the gemfile hashed out while installing from the console, uninstalling and running the Bundle Install with just the gemfile link.
This is the entire Error message I am receiving when trying to access the Rails Console:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in 'require': cannot load such file -- bcrypt_ext (LoadError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `block (2 levels) in require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `each'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `block in require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `each'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler.rb:114:in `require'
from C:/Users/Bill/Documents/Sites/sample_app/config/application.rb:7:in `<top (required)>'
from C:/Ruby23x64/lib/ruby/gems/2.3.0/gems/railties-.1.4/lib/rails/command/actions.rb:15:in `require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:96:in `perform'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in`run'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I am using Ruby version 2.3.3 with Rails version 5.1.4 running on Windows 7x64.
Any insight anyone could offer me at this point would be appreciated.
UPDATE
So after countless hours trying to solve the problem, using the gemfile:
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
was what solved the problem for me. This may not be a permanent solution, but at least it's letting me move forward!
Upvotes: 0
Views: 302
Reputation: 144
There are more recent solutions you may want to explore, but when I had this problem several months ago with Rails 5.0, I used the accepted answer from this stack overflow question and it worked for me.
Update: As suggested, I have added full answer in case link becomes dead. First- Uninstall bcrypt
gem uninstall bcrypt-ruby
Then reinstall
gem install bcrypt --platform=ruby
Then in your Gemfile:
gem 'bcrypt','~>3.1.11' # Or current version
Upvotes: 2