Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot load such file -- bcrypt_ext

I'm currently experiencing the failure of bcrypt's encryptor while using Devise for Rails 5.0.1. I never had this issue before with the earlier Rails 4.2. I can't register new users through Devise. I will post information with regards to my gemfile and server log.

Gemfile.rb

gem 'bcrypt', platforms: :ruby

# Devise
gem 'devise'
gem 'devise_security_extension'

gem 'redis'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'

Server log

Started POST "/register" for 127.0.0.1 at 2017-01-12 13:50:05 -0500
Processing by Users::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"bH6n7iWLhPMECDzTVkMyTc9FXtvkGrq5+K4wFs1g8Bxbjq9ShaLJP5gn72SFQlHc01j2ao5JKcv57ClWAzwsmw==", "user"=>{"email"=>"[email protected]", "username"=>"codex", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
Completed 500 Internal Server Error in 258ms (ActiveRecord: 0.0ms)



LoadError - cannot load such file -- bcrypt_ext:
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `require'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `block in require'
  activesupport (5.0.1) lib/active_support/dependencies.rb:259:in `load_dependency'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `require'
  bcrypt-3.1.11-x86 (mingw32) lib/bcrypt.rb:16:in `rescue in <top (required)>'
  bcrypt-3.1.11-x86 (mingw32) lib/bcrypt.rb:12:in `<top (required)>'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `require'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `block in require'
  activesupport (5.0.1) lib/active_support/dependencies.rb:259:in `load_dependency'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `require'
  devise (4.2.0) lib/devise/encryptor.rb:1:in `<top (required)>'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `require'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `block in require'
  activesupport (5.0.1) lib/active_support/dependencies.rb:259:in `load_dependency'
  activesupport (5.0.1) lib/active_support/dependencies.rb:293:in `require'
  devise (4.2.0) lib/devise/models/database_authenticatable.rb:147:in `password_digest'
  devise (4.2.0) lib/devise/models/database_authenticatable.rb:40:in `password='
  activemodel (5.0.1) lib/active_model/attribute_assignment.rb:46:in `public_send'
  activemodel (5.0.1) lib/active_model/attribute_assignment.rb:46:in `_assign_attribute'
  activemodel (5.0.1) lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
  activemodel (5.0.1) lib/active_model/attribute_assignment.rb:39:in `each'
  activemodel (5.0.1) lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
  activerecord (5.0.1) lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
  activemodel (5.0.1) lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
  activerecord (5.0.1) lib/active_record/core.rb:319:in `initialize'
  activerecord (5.0.1) lib/active_record/inheritance.rb:65:in `new'
  activerecord (5.0.1) lib/active_record/inheritance.rb:65:in `new'
  devise (4.2.0) lib/devise/models/registerable.rb:20:in `new_with_session'
  devise (4.2.0) app/controllers/devise/registrations_controller.rb:100:in `build_resource'
  devise (4.2.0) app/controllers/devise/registrations_controller.rb:15:in `create'
  actionpack (5.0.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
  actionpack (5.0.1) lib/abstract_controller/base.rb:188:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
  actionpack (5.0.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (5.0.1) lib/active_support/callbacks.rb:126:in `call'
  activesupport (5.0.1) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
  activesupport (5.0.1) lib/active_support/callbacks.rb:455:in `call'
  activesupport (5.0.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
  activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
  activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (5.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (5.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  activesupport (5.0.1) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
  activerecord (5.0.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (5.0.1) lib/abstract_controller/base.rb:126:in `process'
  actionview (5.0.1) lib/action_view/rendering.rb:30:in `process'
  actionpack (5.0.1) lib/action_controller/metal.rb:190:in `dispatch'
  actionpack (5.0.1) lib/action_controller/metal.rb:262:in `dispatch'
  actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
  actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
  actionpack (5.0.1) lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>'
  actionpack (5.0.1) lib/action_dispatch/routing/mapper.rb:46:in `serve'
  actionpack (5.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
  actionpack (5.0.1) lib/action_dispatch/journey/router.rb:26:in `each'
  actionpack (5.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
  actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
  rack (2.0.1) lib/rack/deflater.rb:35:in `call'
  warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.6) lib/warden/manager.rb:34:in `catch'
  warden (1.2.6) lib/warden/manager.rb:34:in `call'
  rack (2.0.1) lib/rack/etag.rb:25:in `call'
  rack (2.0.1) lib/rack/conditional_get.rb:38:in `call'
  rack (2.0.1) lib/rack/head.rb:12:in `call'
  rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
  rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
  activerecord (5.0.1) lib/active_record/migration.rb:553:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
  activesupport (5.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
  activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
  activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
  web-console (3.4.0) lib/web_console/middleware.rb:135:in `call_app'
  web-console (3.4.0) lib/web_console/middleware.rb:28:in `block in call'
  web-console (3.4.0) lib/web_console/middleware.rb:18:in `catch'
  web-console (3.4.0) lib/web_console/middleware.rb:18:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  railties (5.0.1) lib/rails/rack/logger.rb:36:in `call_app'
  railties (5.0.1) lib/rails/rack/logger.rb:24:in `block in call'
  activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `block in tagged'
  activesupport (5.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `tagged'
  railties (5.0.1) lib/rails/rack/logger.rb:24:in `call'
  sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
  rack (2.0.1) lib/rack/method_override.rb:22:in `call'
  rack (2.0.1) lib/rack/runtime.rb:22:in `call'
  activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
  rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
  railties (5.0.1) lib/rails/engine.rb:522:in `call'
  puma (3.6.2) lib/puma/configuration.rb:225:in `call'
  puma (3.6.2) lib/puma/server.rb:578:in `handle_request'
  puma (3.6.2) lib/puma/server.rb:415:in `process_client'
  puma (3.6.2) lib/puma/server.rb:275:in `block in run'
  puma (3.6.2) lib/puma/thread_pool.rb:116:in `block in spawn_thread'

Started POST "/__better_errors/4e4442c3f810d7b9/variables" for 127.0.0.1 at 2017-01-12 13:50:06 -0500
like image 448
valcod3r Avatar asked Dec 01 '22 12:12

valcod3r


2 Answers

I had a similar problem today with ruby 2.3.3 and rails 4.2.4.

The problem was that bundle install of devise installed as a dependency another version of bcrypt (bcrypt (3.1.11 x86-mingw32) instead of bcrypt (3.1.11)) which was causing trouble with ruby 2.3 (it should work with all previous versions of ruby)

The solution I used is to install bcrypt outside of the gemfile, run bundle and then remove the second version of bcrypt :

$ gem list bcrypt
bcrypt (3.1.11 x86-mingw32)

$ gem uninstall devise && gem uninstall bcrypt
Successfully uninstalled devise-4.2.0
Successfully uninstalled bcrypt-3.1.11-x86-mingw32

$ gem install bcrypt --platform=Ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed bcrypt-3.1.11
Parsing documentation for bcrypt-3.1.11
Installing ri documentation for bcrypt-3.1.11
Done installing documentation for bcrypt after 1 seconds
1 gem installed

$ gem list bcrypt
bcrypt (3.1.11)

$ bundle install
...
Installing bcrypt 3.1.11 (x86-mingw32)
...
Installing devise 4.2.0
Bundle complete! 25 Gemfile dependencies, 75 gems now installed.

$ gem list bcrypt
bcrypt (3.1.11 ruby x86-mingw32)

$ gem uninstall bcrypt
Select gem to uninstall:
 1. bcrypt-3.1.11
 2. bcrypt-3.1.11-x86-mingw32
 3. All versions
> 2
Successfully uninstalled bcrypt-3.1.11-x86-mingw32

$ gem list bcrypt
bcrypt (3.1.11)

Hope that helps if you haven't solved your problem yet.

like image 190
ManuKpL Avatar answered Dec 06 '22 18:12

ManuKpL


I also encountered the same problem, then I found some references and it's about version only.

When I changed bcrypt back to

bcrypt 3.1.0-x86-mingw32

from

bcrypt 3.1.11-x86-mingw32(the latest now)

Then make sure again in gemfile

gem 'bcrypt-ruby', '3.1.0', :require => 'bcrypt'

then it works fine.

like image 39
Eka putra Avatar answered Dec 06 '22 17:12

Eka putra