doorkeeper-gem / doorkeeper

Doorkeeper is an OAuth 2 provider for Ruby on Rails / Grape.
https://doorkeeper.gitbook.io/guides/
MIT License
5.32k stars 1.07k forks source link

Doorkeeper version 5.5.0 cannot handle custom `application_class` which inherits from `ApplicationRecord` #1492

Closed foton closed 3 years ago

foton commented 3 years ago

Steps to reproduce

We have problem when running rake task in staging environment. Loading environment before task starts fails with "NameError: uninitialized constant ApplicationRecord".

Why? Because we use our override in config/initializers/doorkeeper.rb

application_class 'OauthApplication'

Our OauthApplication inherits from ApplicationRecord.

class OauthApplication < ApplicationRecord
  include ::Doorkeeper::Orm::ActiveRecord::Mixins::Application

  belongs_to :owner, class_name: 'User', optional: true

  validates :grant_flows, presence: true
  validates :owner_id, presence: true, if: -> { grant_flows.include?('client_credentials') }
  validates :redirect_uri, presence: true, if: -> { grant_flows.include?('authorization_code') }

  before_validation :clean_array

  def clean_array
    grant_flows.delete_if(&:blank?)
  end
end

backtrace.txt

In development all is OK, but when we switch to staging rake task fails.

When environment setup requires ApplicationRecord (which inherits from ActiveRecord::Base) Doorkeeper load is triggered. It search for OauthApplication class (which needs, not yet loaded ApplicationRecord)

Shortened backtrace from attachment with comments (full bactrace is attached):

data/base/app/models/oauth_application.rb:25:in `<main>'                                        # => `class OauthApplication < ApplicationRecord`
/data/bundles/base/ruby/2.7.0/gems/doorkeeper-5.5.0/lib/doorkeeper/config.rb:461:in `application_model'
/data/bundles/base/ruby/2.7.0/gems/doorkeeper-5.5.0/lib/doorkeeper/orm/active_record.rb:35:in `block in initialize_application_owner!'
/data/base/app/models/application_record.rb:3:in `<main>'                                       # => `class ApplicationRecord < ActiveRecord::Base`    
/data/base/app/models/user.rb:31:in `<main>'                                                    # => `class User < ApplicationRecord`
/data/bundles/base/ruby/2.7.0/gems/devise-4.7.3/lib/devise/rails/routes.rb:242:in `devise_for'
/data/base/config/routes.rb:23:in `block in <main>'                                             # => `devise_for :users, path_names: { sign_in: 'login', sign_out: 'logout' }`
/data/base/config/routes.rb:6:in `<main>'                                                       # => `Rails.application.routes.draw do`
/data/bundles/base/ruby/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:384:in `initialize!'
/data/base/config/environment.rb:7:in `<main>'
/data/bundles/base/ruby/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:360:in `require_environment!'
/data/bundles/base/ruby/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:526:in `block in run_tasks_blocks'

I tried to setup some Rails app, but I was not able to reproduce the problem.

Expected behavior

Rails environment is loaded and task runs succesfully

Actual behavior

Rails environment fails to load loaded and task runs succesfully

System configuration

Doorkeeper initializer:

# frozen_string_literal: true

Doorkeeper.configure do
  # Change the ORM that doorkeeper will use (requires ORM extensions installed).
  # Check the list of supported ORMs here: https://github.com/doorkeeper-gem/doorkeeper#orms
  orm :active_record

  # This block will be called to check whether the resource owner is authenticated or not.
  resource_owner_authenticator do
    # Put your resource owner authentication logic here.
    current_user || warden.authenticate!(scope: :user)
    # Example implementation:
    #   User.find_by(id: session[:user_id]) || redirect_to(new_user_session_url)
  end

  # This block will be called to check whether the resource owner is authenticated or not.
  resource_owner_from_credentials do
    user = User.find_for_database_authentication(username: params[:username])
    if user&.valid_for_authentication? { user.valid_password?(params[:password]) } && user&.active_for_authentication?
      request.env['warden'].set_user(user, scope: :user, store: false, skip_activity: true)
      user
    end
  end

  # If you didn't skip applications controller from Doorkeeper routes in your application routes.rb
  # file then you need to declare this block in order to restrict access to the web interface for
  # adding oauth authorized applications. In other case it will return 403 Forbidden response
  # every time somebody will try to access the admin web interface.
  #
  # admin_authenticator do
  #   # Put your admin authentication logic here.
  #   # Example implementation:

  #   if current_user
  #     head :forbidden unless current_user.admin?
  #   else
  #     redirect_to sign_in_url
  #   end
  # end

  # You can use your own model classes if you need to extend (or even override) default
  # Doorkeeper models such as `Application`, `AccessToken` and `AccessGrant.
  #
  # Be default Doorkeeper ActiveRecord ORM uses it's own classes:
  #
  # access_token_class "Doorkeeper::AccessToken"
  # access_grant_class "Doorkeeper::AccessGrant"
  application_class 'OauthApplication'
  #
  # Don't forget to include Doorkeeper ORM mixins into your custom models:
  #
  #   *  ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken - for access token
  #   *  ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant - for access grant
  #   *  ::Doorkeeper::Orm::ActiveRecord::Mixins::Application - for application (OAuth2 clients)
  #
  # For example:
  #
  # access_token_class "MyAccessToken"
  #
  # class MyAccessToken < ApplicationRecord
  #   include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken
  #
  #   self.table_name = "hey_i_wanna_my_name"
  #
  #   def destroy_me!
  #     destroy
  #   end
  # end

  # Enables polymorphic Resource Owner association for Access Tokens and Access Grants.
  # By default this option is disabled.
  #
  # Make sure you properly setup you database and have all the required columns (run
  # `bundle exec rails generate doorkeeper:enable_polymorphic_resource_owner` and execute Rails
  # migrations).
  #
  # If this option enabled, Doorkeeper will store not only Resource Owner primary key
  # value, but also it's type (class name). See "Polymorphic Associations" section of
  # Rails guides: https://guides.rubyonrails.org/association_basics.html#polymorphic-associations
  #
  # [NOTE] If you apply this option on already existing project don't forget to manually
  # update `resource_owner_type` column in the database and fix migration template as it will
  # set NOT NULL constraint for Access Grants table.
  #
  # use_polymorphic_resource_owner

  # If you are planning to use Doorkeeper in Rails 5 API-only application, then you might
  # want to use API mode that will skip all the views management and change the way how
  # Doorkeeper responds to a requests.
  #
  # api_only

  # Enforce token request content type to application/x-www-form-urlencoded.
  # It is not enabled by default to not break prior versions of the gem.
  #
  enforce_content_type

  # Authorization Code expiration time (default: 10 minutes).
  #
  authorization_code_expires_in 10.minutes

  # Access token expiration time (default: 2 hours).
  # If you want to disable expiration, set this to `nil`.
  #
  access_token_expires_in 2.hours

  # Assign custom TTL for access tokens. Will be used instead of access_token_expires_in
  # option if defined. In case the block returns `nil` value Doorkeeper fallbacks to
  # +access_token_expires_in+ configuration option value. If you really need to issue a
  # non-expiring access token (which is not recommended) then you need to return
  # Float::INFINITY from this block.
  #
  # `context` has the following properties available:
  #
  # `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
  # `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
  # `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes)
  #
  # custom_access_token_expires_in do |context|
  #   context.client.application.additional_settings.implicit_oauth_expiration
  # end

  # Use a custom class for generating the access token.
  # See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-access-token-generator
  #
  # access_token_generator '::Doorkeeper::JWT'

  # The controller +Doorkeeper::ApplicationController+ inherits from.
  # Defaults to +ActionController::Base+ unless +api_only+ is set, which changes the default to
  # +ActionController::API+. The return value of this option must be a stringified class name.
  # See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-base-controller
  #
  # base_controller 'ApplicationController'

  # Reuse access token for the same resource owner within an application (disabled by default).
  #
  # This option protects your application from creating new tokens before old valid one becomes
  # expired so your database doesn't bloat. Keep in mind that when this option is `on` Doorkeeper
  # doesn't updates existing token expiration time, it will create a new token instead.
  # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
  #
  # You can not enable this option together with +hash_token_secrets+.
  #
  reuse_access_token

  # In case you enabled `reuse_access_token` option Doorkeeper will try to find matching
  # token using `matching_token_for` Access Token API that searches for valid records
  # in batches in order not to pollute the memory with all the database records. By default
  # Doorkeeper uses batch size of 10 000 records. You can increase or decrease this value
  # depending on your needs and server capabilities.
  #
  token_lookup_batch_size 100

  # Set a limit for token_reuse if using reuse_access_token option
  #
  # This option limits token_reusability to some extent.
  # If not set then access_token will be reused unless it expires.
  # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/1189
  #
  # This option should be a percentage(i.e. (0,100])
  #
  token_reuse_limit 80

  # Hash application secrets before persisting them.
  #
  hash_application_secrets
  #
  # By default, applications will be hashed
  # with the +Doorkeeper::SecretStoring::SHA256+ strategy.
  #
  # If you wish to use bcrypt for application secret hashing, uncomment
  # this line instead:
  #
  hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt'

  use_refresh_token

  # Provide support for an owner to be assigned to each registered application (disabled by default)
  # Optional parameter confirmation: true (default: false) if you want to enforce ownership of
  # a registered application
  # NOTE: you must also run the rails g doorkeeper:application_owner generator
  # to provide the necessary support
  #
  enable_application_owner confirmation: false

  # Define access token scopes for your provider
  # For more information go to
  # https://doorkeeper.gitbook.io/guides/ruby-on-rails/scopes
  #
  default_scopes :full_access
  # optional_scopes :write, :update

  # Forbids creating/updating applications with arbitrary scopes that are
  # not in configuration, i.e. +default_scopes+ or +optional_scopes+.
  # (disabled by default)
  #
  enforce_configured_scopes

  # Specify what redirect URI's you want to block during Application creation.
  # Any redirect URI is whitelisted by default.
  #
  # You can use this option in order to forbid URI's with 'javascript' scheme
  # for example.
  #
  forbid_redirect_uri { |uri| uri.scheme.to_s.casecmp('javascript').zero? }

  # Specify how authorization errors should be handled.
  # By default, doorkeeper renders json errors when access token
  # is invalid, expired, revoked or has invalid scopes.
  #
  # If you want to render error response yourself (i.e. rescue exceptions),
  # set +handle_auth_errors+ to `:raise` and rescue Doorkeeper::Errors::InvalidToken
  # or following specific errors:
  #
  #   Doorkeeper::Errors::TokenForbidden, Doorkeeper::Errors::TokenExpired,
  #   Doorkeeper::Errors::TokenRevoked, Doorkeeper::Errors::TokenUnknown
  #
  handle_auth_errors :raise

  # grant_flows %w[authorization_code client_credentials]
  grant_flows %w[authorization_code password client_credentials]

  # @param allow_grant_flow_for_client [Proc] Block or any object respond to #call
  # @return [Boolean] `true` if allow or `false` if forbid the request
  #
  allow_grant_flow_for_client do |grant_flow, client|
    # `grant_flows` is an Array column with grant
    # flows that application supports

    client.grant_flows.include?(grant_flow)
  end

  skip_authorization do |_resource_owner, _client|
    # client.superapp? or resource_owner.admin?
    true
  end
end

Ruby version: 2.7.2

Gemfile.lock:

Gemfile.lock content ``` GIT remote: https://github.com/ciihla/ruby-eet-cz revision: ff2f8267044859ada5b83621514379d641347b4c specs: ruby-eet-cz (1.0.0.pre) activemodel (>= 4.2) activesupport (>= 4.2) savon (~> 2.12.0) GIT remote: https://github.com/rails/rails-controller-testing.git revision: bc6f3356803d7c5d373f89a44625d59953dc0cef branch: master specs: rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) GEM remote: https://rubygems.org/ specs: Ascii85 (1.1.0) aasm (5.1.1) concurrent-ruby (~> 1.0) actioncable (6.1.3) actionpack (= 6.1.3) activesupport (= 6.1.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (6.1.3) actionpack (= 6.1.3) activejob (= 6.1.3) activerecord (= 6.1.3) activestorage (= 6.1.3) activesupport (= 6.1.3) mail (>= 2.7.1) actionmailer (6.1.3) actionpack (= 6.1.3) actionview (= 6.1.3) activejob (= 6.1.3) activesupport (= 6.1.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (6.1.3) actionview (= 6.1.3) activesupport (= 6.1.3) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (6.1.3) actionpack (= 6.1.3) activerecord (= 6.1.3) activestorage (= 6.1.3) activesupport (= 6.1.3) nokogiri (>= 1.8.5) actionview (6.1.3) activesupport (= 6.1.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_model_serializers (0.10.12) actionpack (>= 4.1, < 6.2) activemodel (>= 4.1, < 6.2) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) activejob (6.1.3) activesupport (= 6.1.3) globalid (>= 0.3.6) activejob-status (0.1.6) activejob (>= 4.2) activesupport (>= 4.2) activemodel (6.1.3) activesupport (= 6.1.3) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) activerecord (6.1.3) activemodel (= 6.1.3) activesupport (= 6.1.3) activerecord-clean-db-structure (0.4.0) activerecord (>= 4.2) activerecord-import (1.0.8) activerecord (>= 3.2) activestorage (6.1.3) actionpack (= 6.1.3) activejob (= 6.1.3) activerecord (= 6.1.3) activesupport (= 6.1.3) marcel (~> 0.3.1) mimemagic (~> 0.3.2) activesupport (6.1.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) afm (0.2.2) after_commit_everywhere (1.0.0) activerecord (>= 4.2) akami (1.3.1) gyoku (>= 0.4.0) nokogiri annotate (3.1.1) activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 14.0) ast (2.4.2) auto_strip_attributes (2.6.0) activerecord (>= 4.0) awesome_print (1.8.0) barby (0.6.8) bcrypt (3.1.16) better_errors (2.9.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) bindex (0.8.1) binding.repl (3.0.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) bond (0.5.1) bootsnap (1.7.2) msgpack (~> 1.0) builder (3.2.4) bullet (6.1.4) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) capybara (3.35.3) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) capybara-screenshot (1.0.25) capybara (>= 1.0, < 4) launchy carrierwave (2.2.0) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) image_processing (~> 1.1) mimemagic (>= 0.3.0) mini_mime (>= 0.1.3) ssrf_filter (~> 1.0) case_transform (0.2) activesupport caxlsx (3.0.4) htmlentities (~> 4.3, >= 4.3.4) mimemagic (~> 0.3) nokogiri (~> 1.10, >= 1.10.4) rubyzip (>= 1.3.0, < 3) caxlsx_rails (0.6.2) actionpack (>= 3.1) caxlsx (>= 3.0) cd (1.0.1) childprocess (3.0.0) clipboard (1.3.5) closure_tree (7.2.0) activerecord (>= 4.2.10) with_advisory_lock (>= 4.0.0) code (0.9.3) coderay (~> 1.1) method_source (>= 0.9, < 2.0) coderay (1.1.3) colorize (0.8.1) concurrent-ruby (1.1.8) connection_pool (2.2.3) core_docs (0.9.6) yard (~> 0.9.11) counter_culture (2.7.0) activerecord (>= 4.2) activesupport (>= 4.2) crack (0.4.5) rexml crass (1.0.6) css_parser (1.9.0) addressable damedata_parser_core (0.3.0) ox database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) database_cleaner-active_record (2.0.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) db-query-matchers (0.10.0) activesupport (>= 4.0, < 7) rspec (~> 3.0) debug_inspector (1.0.0) debugging (1.1.2) binding.repl (~> 3.0) paint (>= 0.9, < 3.0) devise (4.7.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) diff-lcs (1.4.4) diffy (3.4.0) docile (1.3.5) doorkeeper (5.5.0) railties (>= 5) draper (4.0.1) actionpack (>= 5.0) activemodel (>= 5.0) activemodel-serializers-xml (>= 1.0) activesupport (>= 5.0) request_store (>= 1.0) em-websocket (0.5.2) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) erubi (1.10.0) et-orbi (1.2.4) tzinfo eventmachine (1.2.7) every_day_irb (2.1.1) cd (~> 1.0) factory_bot (6.1.0) activesupport (>= 5.0.0) factory_bot_rails (6.1.0) factory_bot (~> 6.1.0) railties (>= 5.0.0) fancy_irb (1.4.2) paint (>= 0.9, < 3.0) unicode-display_width (>= 1.1) faraday (1.3.0) faraday-net_http (~> 1.0) multipart-post (>= 1.2, < 3) ruby2_keywords faraday-net_http (1.0.1) ffi (1.14.2) figaro (1.2.0) thor (>= 0.14.0, < 2) formatador (0.2.5) fugit (1.4.2) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) fuubar (2.5.1) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) globalid (0.4.2) activesupport (>= 4.2.0) graphiql-rails (1.7.0) railties sprockets-rails graphql (1.12.5) graphql-rails_logger (1.2.3) actionpack (> 5.0) activesupport (> 5.0) railties (> 5.0) rouge (~> 3.0) graphql_rails (1.2.2) activesupport (>= 4) graphql (~> 1.12, >= 1.12.4) gtin.rb (1.1.1) guard (2.16.2) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) guard-livereload (2.5.2) em-websocket (~> 0.5) guard (~> 2.8) guard-compat (~> 1.0) multi_json (~> 1.8) guard-rspec (4.7.3) guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) gyoku (1.3.1) builder (>= 2.1.2) hashdiff (1.0.1) hashery (2.1.2) hirb (0.7.3) hiredis (0.6.3) htmlentities (4.3.4) http_parser.rb (0.6.0) httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) httpi (2.4.5) rack socksify i18n (1.8.9) concurrent-ruby (~> 1.0) i18n-js (3.8.1) i18n (>= 0.6.6) image_processing (1.12.1) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) inline_svg (1.7.2) activesupport (>= 3.0) nokogiri (>= 1.6) interactive_editor (0.0.11) spoon (>= 0.0.1) io-console (0.5.8) irb (1.3.3) reline (>= 0.1.5) irbtools (3.0.4) binding.repl (~> 3.0) clipboard (~> 1.3) code (>= 0.9.2, < 2.0) coderay (~> 1.1) debugging (~> 1.1) every_day_irb (~> 2.0) fancy_irb (~> 1.2, >= 1.2.1) hirb (~> 0.7, >= 0.7.3) interactive_editor (~> 0.0, >= 0.0.10) irb (>= 0.9.6) methodfinder (~> 2.2) object_shadow (~> 1.1) ori (~> 0.1.0) os paint (>= 0.9, < 3.0) ruby_engine (~> 1.0) ruby_info (~> 1.0) ruby_version (~> 1.0) wirb (~> 2.0, >= 2.2.1) irbtools-more (2.4.1) binding_of_caller (~> 0.8) bond (~> 0.5) core_docs (>= 0.9.5) irbtools (>= 2.2, < 4.0) looksee (~> 4.2) jb (0.8.0) json-schema (2.8.1) addressable (>= 2.4) jsonapi-renderer (0.2.2) kramdown (2.3.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) launchy (2.5.0) addressable (~> 2.7) letter_opener (1.7.0) launchy (~> 2.2) listen (3.4.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) looksee (4.4.0) lumberjack (1.2.8) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) method_source (1.0.0) methodfinder (2.2.1) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2021.0212) mimemagic (0.3.5) mini_magick (4.11.0) mini_mime (1.0.2) mini_portile2 (2.5.0) minitest (5.14.4) msgpack (1.4.2) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) nenv (0.3.0) net-sftp (3.0.0) net-ssh (>= 5.0.0, < 7.0.0) net-ssh (6.1.0) nio4r (2.5.7) nokogiri (1.11.1) mini_portile2 (~> 2.5.0) racc (~> 1.4) nori (2.6.0) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) object_shadow (1.1.1) oj (3.11.2) ori (0.1.0) orm_adapter (0.5.0) os (1.1.1) ougai (2.0.0) oj (~> 3.10) ox (2.14.1) paint (2.2.1) parallel (1.20.1) parallel_tests (3.5.0) parallel parser (3.0.0.0) ast (~> 2.4.1) pdf-core (0.9.0) pdf-inspector (1.3.0) pdf-reader (>= 1.0, < 3.0.a) pdf-reader (2.4.2) Ascii85 (~> 1.0) afm (~> 0.2.1) hashery (~> 2.0) ruby-rc4 ttfunk pg (1.2.3) pohoda (3.1.1) damedata_parser_core (= 0.3.0) ox prawn (2.4.0) pdf-core (~> 0.9.0) ttfunk (~> 1.7) prawn-svg (0.31.0) css_parser (~> 1.6) prawn (>= 0.11.1, < 3) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) pry-byebug (3.9.0) byebug (~> 11.0) pry (~> 0.13.0) public_activity (1.6.4) actionpack (>= 3.0.0) activerecord (>= 3.0) i18n (>= 0.5.0) railties (>= 3.0.0) public_suffix (4.0.6) puma (5.2.2) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) pundit-matchers (1.6.0) rspec-rails (>= 3.0.0) raabro (1.4.0) racc (1.5.2) rack (2.2.3) rack-mini-profiler (2.3.1) rack (>= 1.2.0) rack-proxy (0.6.5) rack rack-test (1.1.0) rack (>= 1.0, < 3) rails (6.1.3) actioncable (= 6.1.3) actionmailbox (= 6.1.3) actionmailer (= 6.1.3) actionpack (= 6.1.3) actiontext (= 6.1.3) actionview (= 6.1.3) activejob (= 6.1.3) activemodel (= 6.1.3) activerecord (= 6.1.3) activestorage (= 6.1.3) activesupport (= 6.1.3) bundler (>= 1.15.0) railties (= 6.1.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) rails_layout (1.0.42) railties (6.1.3) actionpack (= 6.1.3) activesupport (= 6.1.3) method_source rake (>= 0.8.7) thor (~> 1.0) rainbow (3.0.0) rake (13.0.3) ransack (2.4.2) activerecord (>= 5.2.4) activesupport (>= 5.2.4) i18n rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) redis (4.2.5) redis-namespace (1.8.1) redis (>= 3.0.4) regexp_parser (2.1.1) reline (0.2.3) io-console (~> 0.5) request_store (1.5.0) rack (>= 1.4) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) rexml (3.2.4) rouge (3.26.0) rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) rspec-mocks (~> 3.10.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-instafail (1.0.0) rspec rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) rspec-json_expectations (2.2.0) rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-rails (4.1.0) actionpack (>= 4.2) activesupport (>= 4.2) railties (>= 4.2) rspec-core (~> 3.10) rspec-expectations (~> 3.10) rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.10.2) rspec-xml (0.1.1) nokogiri rspec rubocop (1.11.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.4.1) parser (>= 2.7.1.5) rubocop-performance (1.10.1) rubocop (>= 0.90.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.9.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 0.90.0, < 2.0) rubocop-rspec (2.2.0) rubocop (~> 1.0) rubocop-ast (>= 1.1.0) ruby-progressbar (1.11.0) ruby-rc4 (0.1.5) ruby-vips (2.0.17) ffi (~> 1.9) ruby2_keywords (0.0.4) ruby_engine (1.0.1) ruby_info (1.0.1) ruby_version (1.0.2) rubyzip (2.3.0) savon (2.12.1) akami (~> 1.2) builder (>= 2.1.2) gyoku (~> 1.2) httpi (~> 2.3) nokogiri (>= 1.8.1) nori (~> 2.4) wasabi (~> 3.4) scenic (1.5.4) activerecord (>= 4.0.0) railties (>= 4.0.0) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) semantic_range (2.3.1) sentry-raven (3.1.1) faraday (>= 1.0) shellany (0.0.1) sidekiq (6.1.3) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) sidekiq-cron (1.2.0) fugit (~> 1.1) sidekiq (>= 4.2.1) sidekiq-failures (1.0.0) sidekiq (>= 4.0.0) sidekiq-limit_fetch (3.4.0) sidekiq (>= 4) simple_form (5.1.0) actionpack (>= 5.2) activemodel (>= 5.2) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.2) socksify (1.7.1) spoon (0.0.6) ffi sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) ssrf_filter (1.0.7) store_model (0.8.2) activerecord (>= 5.2) switch_user (1.5.4) thor (1.1.0) ttfunk (1.7.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) tzinfo-data (1.2021.1) tzinfo (>= 1.0.0) unicode-display_width (2.0.0) uniform_notifier (1.14.1) vcr (6.0.0) warden (1.2.9) rack (>= 2.0.9) wasabi (3.6.1) addressable httpi (~> 2.0) nokogiri (>= 1.4.2) web-console (4.1.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) webdrivers (4.6.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) webmock (3.12.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webpacker (5.2.1) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (3.3.0) will_paginate-bootstrap4 (0.2.2) will_paginate (~> 3.0, >= 3.0.0) wirb (2.2.2) paint (>= 0.9, < 3.0) with_advisory_lock (4.6.0) activerecord (>= 4.2) xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.26) zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES aasm (= 5.1.1) active_model_serializers (= 0.10.12) activejob-status (= 0.1.6) activemodel-serializers-xml (= 1.0.2) activerecord-clean-db-structure (= 0.4.0) activerecord-import (= 1.0.8) after_commit_everywhere (= 1.0.0) annotate (= 3.1.1) auto_strip_attributes (= 2.6.0) awesome_print (= 1.8.0) barby (= 0.6.8) better_errors (= 2.9.1) binding_of_caller (= 0.8.0) bootsnap (= 1.7.2) bullet (= 6.1.4) capybara (= 3.35.3) capybara-screenshot (= 1.0.25) carrierwave (= 2.2.0) caxlsx (= 3.0.4) caxlsx_rails (= 0.6.2) closure_tree (= 7.2.0) colorize (= 0.8.1) counter_culture (~> 2.7) database_cleaner (= 2.0.1) db-query-matchers (= 0.10.0) devise (= 4.7.3) diffy (= 3.4.0) doorkeeper (= 5.5.0) draper (= 4.0.1) factory_bot_rails (= 6.1.0) figaro (= 1.2.0) fuubar (= 2.5.1) graphiql-rails (= 1.7.0) graphql (= 1.12.5) graphql-rails_logger (= 1.2.3) graphql_rails (= 1.2.2) gtin.rb (= 1.1.1) guard-livereload (= 2.5.2) guard-rspec (= 4.7.3) hiredis (= 0.6.3) httparty (= 0.18.1) i18n-js (= 3.8.1) inline_svg (= 1.7.2) irbtools (= 3.0.4) irbtools-more (= 2.4.1) jb (= 0.8.0) json-schema (= 2.8.1) kramdown (= 2.3.0) kramdown-parser-gfm (= 1.1.0) launchy (= 2.5.0) letter_opener (= 1.7.0) mini_magick (= 4.11.0) net-sftp (= 3.0.0) nokogiri (= 1.11.1) ougai (= 2.0.0) parallel_tests (= 3.5.0) pdf-inspector (= 1.3.0) pg (= 1.2.3) pohoda (= 3.1.1) prawn (= 2.4.0) prawn-svg (= 0.31.0) prawn-table (= 0.2.2) pry-byebug (= 3.9.0) public_activity (= 1.6.4) puma (= 5.2.2) pundit (= 2.1.0) pundit-matchers (= 1.6.0) rack-mini-profiler (= 2.3.1) rails (= 6.1.3) rails-controller-testing! rails-i18n (= 6.0.0) rails_layout (= 1.0.42) ransack (= 2.4.2) rb-fsevent (= 0.10.4) redis-namespace (= 1.8.1) rspec-instafail (= 1.0.0) rspec-its (= 1.3.0) rspec-json_expectations (= 2.2.0) rspec-rails (= 4.1.0) rspec-xml (= 0.1.1) rubocop (= 1.11.0) rubocop-performance (= 1.10.1) rubocop-rails (= 2.9.1) rubocop-rspec (= 2.2.0) ruby-eet-cz! ruby-progressbar (= 1.11.0) scenic (= 1.5.4) sentry-raven (= 3.1.1) sidekiq (= 6.1.3) sidekiq-cron (= 1.2.0) sidekiq-failures (= 1.0.0) sidekiq-limit_fetch (= 3.4.0) simple_form (= 5.1.0) simplecov (= 0.21.2) store_model (= 0.8.2) switch_user (= 1.5.4) tzinfo-data (= 1.2021.1) vcr (= 6.0.0) web-console (= 4.1.0) webdrivers (= 4.6.0) webmock (= 3.12.1) webpacker (= 5.2.1) will_paginate-bootstrap4 (= 0.2.2) RUBY VERSION ruby 2.7.2p137 BUNDLED WITH 2.1.4 ```
foton commented 3 years ago

New discovery: Change OauthApplication < ApplicationRecord to OauthApplication < ActiveRecord::Base will make things work again.

Or downgrading to 5.5.0.rc2is an option.

nbulaj commented 3 years ago

Hm. could be related to https://github.com/doorkeeper-gem/doorkeeper/issues/1489 :thinking: Need to go deeper

nbulaj commented 3 years ago

@foton could you please check your app using gem 'doorkeeper', git: "https://github.com/doorkeeper-gem/doorkeeper.git", branch: "fix-models-autoload" and report if issue still exists?

foton commented 3 years ago

Unfortunatelly, no:

rake aborted!
NameError: uninitialized constant ApplicationRecord
Did you mean?  ApplicationJob
               ApplicationHelper
/home/foton/workspace/queens_base_2/app/models/oauth_application.rb:25:in `<main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `const_get'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `constantize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/doorkeeper-fcdcc2f629fd/lib/doorkeeper/config.rb:465:in `application_model'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/doorkeeper-fcdcc2f629fd/lib/doorkeeper/orm/active_record.rb:37:in `block in initialize_application_owner!'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:51:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.3/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.3/lib/active_record/base.rb:15:in `<main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/home/foton/workspace/queens_base_2/app/models/application_record.rb:3:in `<main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
/home/foton/workspace/queens_base_2/app/models/user.rb:31:in `<main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `const_get'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `constantize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies/zeitwerk_integration.rb:19:in `constantize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise.rb:316:in `get'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/mapping.rb:83:in `to'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/mapping.rb:78:in `modules'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/mapping.rb:95:in `routes'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/mapping.rb:162:in `default_used_route'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/mapping.rb:72:in `initialize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise.rb:346:in `new'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise.rb:346:in `add_mapping'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/rails/routes.rb:243:in `block in devise_for'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/rails/routes.rb:242:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/devise-4.7.3/lib/devise/rails/routes.rb:242:in `devise_for'
/home/foton/workspace/queens_base_2/config/routes.rb:23:in `block in <main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/actionpack-6.1.3/lib/action_dispatch/routing/route_set.rb:427:in `instance_exec'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/actionpack-6.1.3/lib/action_dispatch/routing/route_set.rb:427:in `eval_block'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/actionpack-6.1.3/lib/action_dispatch/routing/route_set.rb:409:in `draw'
/home/foton/workspace/queens_base_2/config/routes.rb:6:in `<main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:47:in `block in load_paths'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:47:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:47:in `load_paths'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:21:in `reload!'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:35:in `block in updater'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/file_update_checker.rb:83:in `execute'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/routes_reloader.rb:10:in `execute'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application/finisher.rb:195:in `block in <module:Finisher>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:32:in `instance_exec'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:32:in `run'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `call'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/initializable.rb:60:in `run_initializers'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:384:in `initialize!'
/home/foton/workspace/queens_base_2/config/environment.rb:7:in `<main>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:360:in `require_environment!'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/application.rb:526:in `block in run_tasks_blocks'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:83:in `block in run'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:80:in `run'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/home/foton/.asdf/installs/ruby/2.7.2/bin/rake:23:in `load'
/home/foton/.asdf/installs/ruby/2.7.2/bin/rake:23:in `<top (required)>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/cli.rb:476:in `exec'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/cli.rb:24:in `start'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:46:in `block in <top (required)>'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/home/foton/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:34:in `<top (required)>'
/home/foton/.asdf/installs/ruby/2.7.2/bin/bundle:23:in `load'
/home/foton/.asdf/installs/ruby/2.7.2/bin/bundle:23:in `<main>'
Tasks: TOP => deploy:run_empty => verbose => environment
nbulaj commented 3 years ago

Removed the hack for rake tasks, you can try once again (bundle update this branch). If it doesn't help - then there is more magic with autoloading and env setup :no_good:

foton commented 3 years ago

Sorry to say, but still got the error.

nbulaj commented 3 years ago

Hi @foton . I moved some ORM loading code under engine after_initializer , could you please run bundle update for Doorkeeper from the branch I mentioned above and try again? Thanks!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

foton commented 3 years ago

@nbulaj I seems fixed in 5.5.2. Thanks

KazWolfe commented 2 years ago

I regret to bring this up, but I'm able to reproduce this behavior on 5.5.4 with Rails 7.0.3.1 on Ruby 3.1.2, although I'm using a class in a module (Oauth::ClientApplication). I can trigger this reliably with rails g controller something.

class Oauth::ClientApplication < ApplicationRecord
  include ::Doorkeeper::Orm::ActiveRecord::Mixins::Application
end
/app/app/models/oauth/client_application.rb:1:in `<main>': uninitialized constant ApplicationRecord (NameError)

class Oauth::ClientApplication < ApplicationRecord
                                 ^^^^^^^^^^^^^^^^^
Did you mean?  ApplicationJob
               ApplicationHelper

It seems to work with ActionRecord::Base at least.

markevich commented 1 year ago

Got the same error with 5.54 and rails 7+ with ruby 3.1+

I have set a custom class in initializer application_class "OauthApplication"

Here is the content of the file:

class OauthApplication < PrimaryRecord
  include ::Doorkeeper::Orm::ActiveRecord::Mixins::Application
end

And I have the same error as @KazWolfe

Failure/Error:
  class OauthApplication < PrimaryRecord
    include ::Doorkeeper::Orm::ActiveRecord::Mixins::Application

NameError:
  uninitialized constant PrimaryRecord

  class OauthApplication < PrimaryRecord

The problem is that I need to use PrimaryRecord because I have two databases witch lives under different AR root models.

Are the any suggestions how that can be fixed?

Thanks!

markevich commented 1 year ago

never mind, it fixes itself with doorkeeper 5.6.5 version