Following an upgrade from Rails 5.0 to 5.1 I'm getting this error anytime the app reloads, either from code changes during rails server or if I call reload! from the console.
🌶 13:53$ rc
Loading development environment (Rails 5.1.1)
2.3.1 :001 > reload!
Reloading...
ArgumentError: unknown firstpos: NilClass
from (irb):1
2.3.1 :002 >
https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/journey/gtg/builder.rb
Application Trace is empty, here's the Framework Trace:
actionpack (5.1.1) lib/action_dispatch/journey/gtg/builder.rb:99:in `firstpos'
actionpack (5.1.1) lib/action_dispatch/journey/gtg/builder.rb:22:in `transition_table'
actionpack (5.1.1) lib/action_dispatch/journey/routes.rb:58:in `simulator'
actionpack (5.1.1) lib/action_dispatch/journey/router.rb:92:in `simulator'
actionpack (5.1.1) lib/action_dispatch/journey/router.rb:28:in `eager_load!'
actionpack (5.1.1) lib/action_dispatch/routing/route_set.rb:382:in `eager_load!'
railties (5.1.1) lib/rails/application/routes_reloader.rb:26:in `each'
railties (5.1.1) lib/rails/application/routes_reloader.rb:26:in `execute'
railties (5.1.1) lib/rails/application/finisher.rb:141:in `block (2 levels) in <module:Finisher>'
activesupport (5.1.1) lib/active_support/callbacks.rb:413:in `instance_exec'
activesupport (5.1.1) lib/active_support/callbacks.rb:413:in `block in make_lambda'
activesupport (5.1.1) lib/active_support/callbacks.rb:197:in `block (2 levels) in halting'
activesupport (5.1.1) lib/active_support/callbacks.rb:601:in `block (2 levels) in default_terminator'
activesupport (5.1.1) lib/active_support/callbacks.rb:600:in `catch'
activesupport (5.1.1) lib/active_support/callbacks.rb:600:in `block in default_terminator'
activesupport (5.1.1) lib/active_support/callbacks.rb:198:in `block in halting'
activesupport (5.1.1) lib/active_support/callbacks.rb:507:in `block in invoke_before'
activesupport (5.1.1) lib/active_support/callbacks.rb:507:in `each'
activesupport (5.1.1) lib/active_support/callbacks.rb:507:in `invoke_before'
activesupport (5.1.1) lib/active_support/callbacks.rb:130:in `run_callbacks'
activesupport (5.1.1) lib/active_support/execution_wrapper.rb:108:in `run!'
activesupport (5.1.1) lib/active_support/reloader.rb:113:in `run!'
activesupport (5.1.1) lib/active_support/execution_wrapper.rb:70:in `block in run!'
activesupport (5.1.1) lib/active_support/execution_wrapper.rb:67:in `tap'
activesupport (5.1.1) lib/active_support/execution_wrapper.rb:67:in `run!'
activesupport (5.1.1) lib/active_support/reloader.rb:59:in `run!'
actionpack (5.1.1) lib/action_dispatch/middleware/executor.rb:10:in `call'
actionpack (5.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
actionpack (5.1.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.1) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.1) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.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.1.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
request_store (1.3.2) lib/request_store/middleware.rb:9:in `call'
actionpack (5.1.1) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/method_override.rb:22:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.1) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
railties (5.1.1) lib/rails/engine.rb:522:in `call'
puma (3.9.1) lib/puma/configuration.rb:224:in `call'
puma (3.9.1) lib/puma/server.rb:602:in `handle_request'
puma (3.9.1) lib/puma/server.rb:435:in `process_client'
puma (3.9.1) lib/puma/server.rb:299:in `block in run'
puma (3.9.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
I just faced exactly the same problem. I sovled it by setting:
config/environments/development.rb
from:
# Do not eager load code on boot.
config.eager_load = true
to:
**# Do not eager load code on boot.
config.eager_load = false
Hope this helps!
Cheers, Nic.
Workaround found! https://github.com/rails/rails/pull/32296
The pull request is not merged, and will probably only be in 5.2+ anyway. Adding a monkey patch with the one-line change fixed the problem entirely for me.
config/initializers/routes.rb
# MONKEY PATCH!!!
# https://github.com/rails/rails/pull/32296
#
# Fixes:
# * Development mode deadlocks
# * ArgumentError: unknown firstpos: NilClass
#
# Allows use of "config.eager_load = true"
module ActionDispatch
module Journey
class Routes
def simulator
#simulator ||= begin
gtg = GTG::Builder.new(ast).transition_table unless ast.blank?
GTG::Simulator.new(gtg)
end
end
end
end
end
Seems it is Spring hanging or something. Just run spring stop and it should go away. Alternatively you can start the rails console without spring like this:
DISABLE_SPRING=true rails c.
I started having this problem after upgrading Rails from 5.1 to 5.2
It got solved by:
spring stop
spring binstub --all
spring start
rails s
You will not get this bug in production environment and in a test environment (if you don't use Spring).
Because this bug "ArgumentError: unknown firstpos: NilClass" you got in "reload" when it tried to reload some your classes.
In production and test environments all things are in cache, so all your things will be cached and bug will not happen
Unfortunately (for now) for the development environment, I also found only this solution
config.eager_load = false
Related
I am building an embedded Shopify application on Rails 6.0.3.2 and using the most recent version of the mongoid gem to make use of MongoDB. I am also using the most recent version of the shopify_app gem.
gem 'mongoid', '7.1.4'
gem 'shopify_app', '15.0.0'
My issue arises when trying to access one of my own controllers via a POST request. In this specific instance, it is a create controller for creating orders via the Shopify::API.
I believe the error has something to do with the authenticating going on in the background for embedded apps.
This error only happens when the calling controller is inheriting from the AuthenticatedController. Which is a controller generated by the shopify_app gem and required for authentication purposes, and that is required to make use of the Shopify::API inside of an embedded app.. If I simply change to < ApplicationController
The error goes away. This error happens without actually trying to access Mongo from the controller, even when calling an empty controller, though only one accessed by a POST request, controllers accessed via GET requests work fine. I even have one controller that has a working create action when inheriting from ApplicationController that breaks as soon as it inherits from AuthenticatedController. This is why I believe it has to do with background authentication between the embedded_app and the store.
This error can be seen below
Mongo::Error::OperationFailure in OrderFulfillmentsController#update_orders
unknown operator: $oid (2) (on localhost:27017, modern retry, attempt 1)
Application Trace | Framework Trace | Full Trace
mongo (2.13.1) lib/mongo/operation/result.rb:321:in raise_operation_failure' mongo (2.13.1) lib/mongo/operation/result.rb:289:in validate!'
mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:29:in block (3 levels) in validate_result' mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:96:in add_server_diagnostics'
mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:28:in block (2 levels) in validate_result' mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:43:in add_error_labels'
mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:27:in block in validate_result' mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:82:in unpin_maybe'
mongo (2.13.1) lib/mongo/operation/shared/response_handling.rb:26:in validate_result' mongo (2.13.1) lib/mongo/operation/shared/executable.rb:45:in block in execute'
mongo (2.13.1) lib/mongo/operation/shared/executable.rb:44:in tap' mongo (2.13.1) lib/mongo/operation/shared/executable.rb:44:in execute'
mongo (2.13.1) lib/mongo/operation/shared/op_msg_or_find_command.rb:29:in block in execute' mongo (2.13.1) lib/mongo/server/connection_pool.rb:590:in with_connection'
mongo (2.13.1) lib/mongo/server.rb:425:in with_connection' mongo (2.13.1) lib/mongo/operation/shared/op_msg_or_find_command.rb:27:in execute'
mongo (2.13.1) lib/mongo/collection/view/iterable.rb:104:in send_initial_query' mongo (2.13.1) lib/mongo/collection/view/iterable.rb:46:in block in each'
mongo (2.13.1) lib/mongo/retryable.rb:61:in block in read_with_retry_cursor' mongo (2.13.1) lib/mongo/retryable.rb:316:in modern_read_with_retry'
mongo (2.13.1) lib/mongo/retryable.rb:117:in read_with_retry' mongo (2.13.1) lib/mongo/retryable.rb:60:in read_with_retry_cursor'
/usr/share/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/forwardable.rb:235:in read_with_retry_cursor' mongo (2.13.1) lib/mongo/collection/view/iterable.rb:45:in each'
mongoid (7.1.4) lib/mongoid/query_cache.rb:228:in each' mongoid (7.1.4) lib/mongoid/contextual/mongo.rb:282:in first'
mongoid (7.1.4) lib/mongoid/contextual/mongo.rb:282:in find_first' /usr/share/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/forwardable.rb:235:in find_first'
mongoid (7.1.4) lib/mongoid/findable.rb:119:in find_by' shopify_app (15.0.0) lib/shopify_app/session/shop_session_storage.rb:20:in retrieve'
shopify_app (15.0.0) lib/shopify_app/session/session_repository.rb:12:in retrieve_shop_session' shopify_app (15.0.0) lib/shopify_app/controller_concerns/login_protection.rb:76:in shop_session_by_cookie'
shopify_app (15.0.0) lib/shopify_app/controller_concerns/login_protection.rb:65:in shop_session' shopify_app (15.0.0) lib/shopify_app/controller_concerns/login_protection.rb:45:in current_shopify_session'
shopify_app (15.0.0) lib/shopify_app/controller_concerns/login_protection.rb:89:in login_again_if_different_user_or_shop' activesupport (6.0.3.4) lib/active_support/callbacks.rb:428:in block in make_lambda'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:200:in block (2 levels) in halting' actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:34:in block (2 levels) in module:Callbacks'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:201:in block in halting' activesupport (6.0.3.4) lib/active_support/callbacks.rb:513:in block in invoke_before'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:513:in each' activesupport (6.0.3.4) lib/active_support/callbacks.rb:513:in invoke_before'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:110:in block in run_callbacks' activesupport (6.0.3.4) lib/active_support/callbacks.rb:139:in run_callbacks'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:41:in process_action' actionpack (6.0.3.4) lib/action_controller/metal/rescue.rb:22:in process_action'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:33:in block in process_action' activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in instrument' activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in instrument'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:32:in process_action' actionpack (6.0.3.4) lib/action_controller/metal/params_wrapper.rb:245:in process_action'
mongoid (7.1.4) lib/mongoid/railties/controller_runtime.rb:22:in process_action' actionpack (6.0.3.4) lib/abstract_controller/base.rb:136:in process'
actionview (6.0.3.4) lib/action_view/rendering.rb:39:in process' actionpack (6.0.3.4) lib/action_controller/metal.rb:190:in dispatch'
actionpack (6.0.3.4) lib/action_controller/metal.rb:254:in dispatch' actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:50:in dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:33:in serve' actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:49:in block in serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in each' actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in serve'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:834:in call' omniauth (1.9.1) lib/omniauth/strategy.rb:192:in call!'
omniauth (1.9.1) lib/omniauth/strategy.rb:169:in call' omniauth (1.9.1) lib/omniauth/builder.rb:45:in call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in call' rack (2.2.3) lib/rack/etag.rb:27:in call'
rack (2.2.3) lib/rack/conditional_get.rb:40:in call' rack (2.2.3) lib/rack/head.rb:12:in call'
actionpack (6.0.3.4) lib/action_dispatch/http/content_security_policy.rb:18:in call' rack (2.2.3) lib/rack/session/abstract/id.rb:266:in context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in call' actionpack (6.0.3.4) lib/action_dispatch/middleware/cookies.rb:648:in call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:27:in block in call' activesupport (6.0.3.4) lib/active_support/callbacks.rb:101:in run_callbacks'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:26:in call' actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in call' actionpack (6.0.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:32:in call'
web-console (4.1.0) lib/web_console/middleware.rb:132:in call_app' web-console (4.1.0) lib/web_console/middleware.rb:19:in block in call'
web-console (4.1.0) lib/web_console/middleware.rb:17:in catch' web-console (4.1.0) lib/web_console/middleware.rb:17:in call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in call' railties (6.0.3.4) lib/rails/rack/logger.rb:37:in call_app'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in block in call' activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in block in tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:28:in tagged' activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in tagged'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in call' sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/remote_ip.rb:81:in call' actionpack (6.0.3.4) lib/action_dispatch/middleware/request_id.rb:27:in call'
rack (2.2.3) lib/rack/method_override.rb:24:in call' shopify_app (15.0.0) lib/shopify_app/middleware/jwt_middleware.rb:23:in call_next'
shopify_app (15.0.0) lib/shopify_app/middleware/jwt_middleware.rb:11:in call' shopify_app (15.0.0) lib/shopify_app/middleware/same_site_cookie_middleware.rb:11:in call'
rack (2.2.3) lib/rack/runtime.rb:22:in call' activesupport (6.0.3.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in call' actionpack (6.0.3.4) lib/action_dispatch/middleware/static.rb:126:in call'
rack (2.2.3) lib/rack/sendfile.rb:110:in call' actionpack (6.0.3.4) lib/action_dispatch/middleware/host_authorization.rb:82:in call'
webpacker (4.3.0) lib/webpacker/dev_server_proxy.rb:23:in perform_request' rack-proxy (0.6.5) lib/rack/proxy.rb:57:in call'
railties (6.0.3.4) lib/rails/engine.rb:527:in call' puma (4.3.6) lib/puma/configuration.rb:228:in call'
puma (4.3.6) lib/puma/server.rb:713:in handle_request' puma (4.3.6) lib/puma/server.rb:472:in process_client'
puma (4.3.6) lib/puma/server.rb:328:in block in run' puma (4.3.6) lib/puma/thread_pool.rb:134:in block in spawn_thread'
This can be solved by defining the following method on your Shop class. Located at Shop.rb
def id
_id.to_s
end
I believe this is due to the fact that MongoDB defines _ids as a BSON object by default, but the authentication workflow is looking for a string.
I have a rails (v5.1) project in development, in which I recently installed Sidekiq. I now have an autoload issue, getting the subject argument error.
I have done a fair bit of research which seem to boil down to this being a problem of "trying to access an automatically reloaded class (in app directory) from one that is not automatically reloaded (in lib directory)," and that when the code is reloaded, Rails throws an error since the module from which the constant search is starting shouldn't be there but is. In my case Rails appears to be trying to autoload controllers under "api/v1." Key reference here.
Apparently, the problem can also be related to threading when a constant is loaded in another thread when autoload is trying to load the same constant in a different thread. I've read that the issue could be dealt with by "require" or "require_dependency" to make sure the code is loaded before it is attempted to be autoloaded by Rails, but I have not figured out where I can require controllers before autoload. Any insights?
I cannot seem to find issues with file naming conventions, which seems to be one reason for this error. I've tried putting "::" in different places, but to no avail. I can set "config.eager_load: true" in development.rb to run the code error free but that leaves open other issues.
********* UPDATE *********
I tried changing the thread pool size in /config/puma.rb from 5 to 1, and the ArgumentError disappeared. This suggests a threading issue described above and in this post, and not with a autoloaded constant in a non-autoloaded one. I have pretty much concluded that Sidekiq just is not compatible to Rails autoloading due to threading, but does anyone know how to deal with this?
config/puma.rb
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
to
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 1 }
********* UPDATE *********
Could the contents in my lib directory be the problem? If so, how can I get around this?
My app has only one file in lib directory for the responders gem, application_responder.rb, which references ActionController. Could this reference to be a problem? File contents are below:
/lib/application_responder.rb
class ApplicationResponder < ActionController::Responder
include Responders::FlashResponder
include Responders::HttpCacheResponder
end
The application_controller.rb file refers to responders as below:
/app/controllers/application_controller.rb
require "application_responder"
class ApplicationController < ActionController::API
self.responder = ApplicationResponder
respond_to :html
include ActionController::MimeResponds
include Response
...
end
Error logs:
ArgumentError (A copy of Api::V1 has been removed from the module tree but is still active!):
ArgumentError (A copy of Api::V1 has been removed from the module tree but is still active!):
/usr/local/Cellar/rbenv/1.1.2/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:457: warning: already initialized constant Api
/usr/local/Cellar/rbenv/1.1.2/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:457: warning: previous definition of Api was here
activesupport (5.1.5) lib/active_support/dependencies.rb:496:in `load_missing_constant'
activesupport (5.1.5) lib/active_support/dependencies.rb:202:in `const_missing'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:271:in `const_get'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:271:in `block in constantize'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:267:in `each'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:267:in `inject'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:267:in `constantize'
activesupport (5.1.5) lib/active_support/dependencies.rb:583:in `get'
activesupport (5.1.5) lib/active_support/dependencies.rb:614:in `constantize'
actionpack (5.1.5) lib/action_dispatch/http/request.rb:85:in `controller_class_for'
actionpack (5.1.5) lib/action_dispatch/http/parameters.rb:99:in `binary_params_for?'
actionpack (5.1.5) lib/action_dispatch/http/parameters.rb:90:in `set_binary_encoding'
actionpack (5.1.5) lib/action_dispatch/http/parameters.rb:67:in `path_parameters='
actionpack (5.1.5) lib/action_dispatch/journey/router.rb:48:in `block in serve'
actionpack (5.1.5) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.5) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.5) lib/action_dispatch/routing/route_set.rb:844:in `call'
bullet (5.6.1) lib/bullet/rack.rb:12:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.4) lib/rack/etag.rb:25:in `call'
rack (2.0.4) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.4) lib/rack/head.rb:12:in `call'
activerecord (5.1.5) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.5) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.5) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.5) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.5) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.5) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
railties (5.1.5) lib/rails/engine.rb:522:in `call'
puma (3.11.3) lib/puma/configuration.rb:225:in `call'
puma (3.11.3) lib/puma/server.rb:624:in `handle_request'
puma (3.11.3) lib/puma/server.rb:438:in `process_client'
puma (3.11.3) lib/puma/server.rb:302:in `block in run'
puma (3.11.3) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
/usr/local/Cellar/rbenv/1.1.2/versions/2.7.1/lib/ruby/gems/2.7.0/gems/json-2.1.0/lib/json/common.rb:156: warning: Using the last argument as keyword parameters is deprecated
I just start using rails and now doing some basic drills to handle requests. I've created the project with rails new (project_name) --api --skip-active-record and following this video: https://www.youtube.com/watch?v=QojnRc7SS9o, since I don't want to use database yet so I added the --skip-active-record
...After tons of uninitialized errors, I added this line in application.rb
config.after_initialize do
# it should be defined in 'application_controller.rb'
puts "def: #{defined? ApplicationController}" # => nil
end
then I run rails s it says it's undefined(aka nil)...
Of course I can require the app folder manually, but it seems just reinvent the wheel, any way to fix this?
Additional info I run with the command that googled from another article, maybe will help:
>> ruby bin/rails runner "ActiveSupport::Dependencies.autoload_paths.each{|line| puts line}"
F:/Programming/RoR/api_test/app/channels
F:/Programming/RoR/api_test/app/controllers
F:/Programming/RoR/api_test/app/controllers/concerns
F:/Programming/RoR/api_test/app/jobs
F:/Programming/RoR/api_test/app/mailers
F:/Programming/RoR/api_test/app/models
F:/Programming/RoR/api_test/app/models/concerns
F:/Programming/RoR/api_test/test/mailers/previews
Edit: The full error trace of the uninitiated error:
Started GET "/api/v0/handshake" for ::1 at 2019-07-11 17:24:30 +0800
ActionController::RoutingError (uninitialized constant Api::V0::HandshakeController):
activesupport (5.2.3) lib/active_support/inflector/methods.rb:285:in `const_get'
activesupport (5.2.3) lib/active_support/inflector/methods.rb:285:in `block in constantize'
activesupport (5.2.3) lib/active_support/inflector/methods.rb:281:in `each'
activesupport (5.2.3) lib/active_support/inflector/methods.rb:281:in `inject'
activesupport (5.2.3) lib/active_support/inflector/methods.rb:281:in `constantize'
actionpack (5.2.3) lib/action_dispatch/http/request.rb:88:in `controller_class_for'
actionpack (5.2.3) lib/action_dispatch/http/request.rb:81:in `controller_class'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:46:in `controller'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
My controller file (path: app/controllers/api/v0/handshake.rb)
module Api
module V0
class HandshakeController < ApplicationController
def index
render json: {status: 'SUCCESS', message: 'Hello World!'}, status: :ok
end
end
end
end
and the routes.rb
Rails.application.routes.draw do
namespace 'api' do
namespace 'v0' do
resources :handshake
end
end
end
OK I got it. The problem is my filename is unmatched with the rail's autoload file structure as it says here, after I renamed handshake.rb to handshake_controller.rb and it worked
I just started receiving this error for all controller.
Not sure what happened, because I was working on UI so CSS, ERB files and then I reload the page and start getting this error.
Thanks for any advice and help.
Controllers: (app/controllers/...)
home_controller.rb
application_controller.rb
In home_controller:
class HomeController < ApplicationController
def index
end
end
In application_controller:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
Routes:
Rails.application.routes.draw do
devise_for :admins, path: '', path_names: { sign_in: 'login', sign_out: 'logout'}
# HOME
root to: 'home#index'
# MESSENGER
match '/webhook', :controller => 'messenger', :action => 'callback', :via => :post
get '/webhook' => 'messenger#verify_callback'
end
Error: (for all controllers same error except constant and path)
LoadError (Unable to autoload constant HomeController, expected /home/ubuntu/line/app/controllers/home_controller.rb to define it):
activesupport (5.0.1) lib/active_support/dependencies.rb:512:in `load_missing_constant'
activesupport (5.0.1) lib/active_support/dependencies.rb:203:in `const_missing'
activesupport (5.0.1) lib/active_support/inflector/methods.rb:268:in `const_get'
activesupport (5.0.1) lib/active_support/inflector/methods.rb:268:in `block in constantize'
activesupport (5.0.1) lib/active_support/inflector/methods.rb:266:in `each'
activesupport (5.0.1) lib/active_support/inflector/methods.rb:266:in `inject'
activesupport (5.0.1) lib/active_support/inflector/methods.rb:266:in `constantize'
activesupport (5.0.1) lib/active_support/dependencies.rb:583:in `get'
activesupport (5.0.1) lib/active_support/dependencies.rb:614:in `constantize'
actionpack (5.0.1) lib/action_dispatch/http/request.rb:81:in `controller_class'
actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:44:in `controller'
actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:30: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'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.1) lib/rack/etag.rb:25:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:25: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'
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:20: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'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (3.1ms)
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.3ms)
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.8ms)
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (20.3ms)
Started POST "/webhook" for 66.220.152.184 at 2017-02-20 04:02:49 +0000
Cannot render console from 66.220.152.184! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
LoadError (Unable to autoload constant ApplicationController, expected /home/ubuntu/line/app/controllers/application_controller.rb to define it):
app/controllers/messenger_controller.rb:3:in `<top (required)>'
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (3.2ms)
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.6ms)
Rendering /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.1ms)
Rendered /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (22.7ms)
This is not a routes issue. The problem is a constant resolution issue (plus autoloading) because it is saying it's not finding the HomeController class in home_controller.rb, despite the fact that it's defined there.
Try restarting the server process. Even though autoloading should handle any changes to classes, sometimes I've seen it fail. I've also seen the same issue happen with the spring preloader.
If this doesn't work, can you let us know whether you're using an IDE, and what happens if you try to interact with the ApplicationController class within the console.
As you mentioned that all your controllers are giving this error please check in file application.rb and add this line or a similar to below
config.autoload_paths += %W(#{config.root}/controllers)
The above may be because of some change in your application.rb your getting this error which is preventing it from auto loading all your controllers
I'm using C9 and ssh for AWS server.. The problem was in C9, because it didn't sync the files well, so when I close the file and reopen it, the files were empty..
In case if someone is using C9 and will have the same problem as me.
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"=>"craigcarl#codex.com", "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
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.
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.
I also face this same issue for ruby '2.3.3' and rails '5.2.0' but the only solution right now is to run:
gem uninstall bcrypt
gem install bcrypt --platform=ruby
temporary fix.
Maybe it's just the native binary is wrongly built or corrupted. Try below
Open a command console
cd to the gem directory C:\RailsInstaller\Ruby2.2.0\lib\ruby\gems\2.2.0\gems\bcrypt-3.1.10-x86-mingw32\ext\mri
Run ruby extconf.rb. It should create the Makefile
Run make. It will builde the extension libraries.
Run make install
See more at Fix issue "cannot load such file -- bcrypt_ext (LoadError)"
These steps to fix issue in MS Win 10 and 8
Uninstall all bcrypt
gem uninstall bcrypt
Go on lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/ and copy bcrypt_ext.so file. and paste on desktop for now.
Uninstall all bcrypt again
gem uninstall bcrypt
Add in your project's gemfile
gem 'bcrypt', '~> 3.1.7'
Run commands
bundle install
bundle update
Paste copied bcrypt_ext.so in folder lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/ from desktop.
Restart server
rails server
It works on win 7 and 10!!!