Closed ahaverty closed 4 years ago
It's because with Rails 6 it uses Zeitwerk and initielizers calls your custom classes which wasn't loaded yet. You need to configure Zeitwerk somehow, I can't give you an answer right now on how to do it
could you try remove config.autoload_paths << "#{Rails.root}/lib"
? and in your custom classes, don't do any require
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.
I found that wrapping some constant calls in a to_prepare
block in doorkeeper.rb
initializer silences this warning (using the example above):
Rails.application.config.to_prepare do
Doorkeeper::OAuth::TokenResponse.send :prepend, CustomTokenResponse
Doorkeeper::OAuth::ErrorResponse.send :prepend, CustomTokenErrorResponse
end
This is documented in an article: https://www.danott.co/today-i-learned/2019-10-16/ And a Rails issue: https://github.com/rails/rails/issues/36363
Steps to reproduce
Following the guide on custom token responses, Rails now gives me deprecation warnings about the two constants that I setup. https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-Token-Response The guide works, and my custom responses are working. But on running rspec, I'm seeing this:
Expected behavior
No deprecation warnings
Actual behavior
See reproduction steps☝️
System configuration
Standard ruby/rails app, with devise and doorkeeper for our api endpoints.
Doorkeeper initializer:
Ruby version:
2.5.0
Gemfile.lock:
Gemfile.lock content
``` GEM remote: https://rubygems.org/ specs: actioncable (6.0.0) actionpack (= 6.0.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (6.0.0) actionpack (= 6.0.0) activejob (= 6.0.0) activerecord (= 6.0.0) activestorage (= 6.0.0) activesupport (= 6.0.0) mail (>= 2.7.1) actionmailer (6.0.0) actionpack (= 6.0.0) actionview (= 6.0.0) activejob (= 6.0.0) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (6.0.0) actionview (= 6.0.0) activesupport (= 6.0.0) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (6.0.0) actionpack (= 6.0.0) activerecord (= 6.0.0) activestorage (= 6.0.0) activesupport (= 6.0.0) nokogiri (>= 1.8.5) actionview (6.0.0) activesupport (= 6.0.0) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) activejob (6.0.0) activesupport (= 6.0.0) globalid (>= 0.3.6) activemodel (6.0.0) activesupport (= 6.0.0) activerecord (6.0.0) activemodel (= 6.0.0) activesupport (= 6.0.0) activestorage (6.0.0) actionpack (= 6.0.0) activejob (= 6.0.0) activerecord (= 6.0.0) marcel (~> 0.3.1) activesupport (6.0.0) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.1, >= 2.1.8) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) allowable (1.1.0) ast (2.4.0) aws-eventstream (1.0.3) aws-partitions (1.221.0) aws-sdk-core (3.68.1) aws-eventstream (~> 1.0, >= 1.0.2) aws-partitions (~> 1.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) aws-sdk-kms (1.24.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sigv4 (~> 1.1) aws-sdk-s3 (1.48.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) aws-sigv4 (1.1.0) aws-eventstream (~> 1.0, >= 1.0.2) bcrypt (3.1.13) better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) bindex (0.8.1) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) bootsnap (1.4.5) msgpack (~> 1.0) bootstrap-email (0.2.6) actionmailer (>= 3) nokogiri (~> 1.6) premailer-rails (~> 1.9) rails (>= 3) builder (3.2.3) bullet (6.0.2) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.0.1) capybara (3.29.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (~> 1.5) xpath (~> 3.2) capybara-screenshot (1.0.23) capybara (>= 1.0, < 4) launchy childprocess (3.0.0) cliver (0.3.2) cocoon (1.2.14) coderay (1.1.2) concurrent-ruby (1.1.5) connection_pool (2.2.2) crass (1.0.4) css_parser (1.7.0) addressable database_cleaner (1.7.0) debug_inspector (0.0.3) devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) devise_invitable (2.0.1) actionmailer (>= 5.0) devise (>= 4.6) diff-lcs (1.3) docile (1.3.2) doorkeeper (5.2.2) railties (>= 5) dropybara (1.0.0) erubi (1.8.0) factory_bot (5.0.2) activesupport (>= 4.2.0) factory_bot_rails (5.0.2) factory_bot (~> 5.0.2) railties (>= 4.2.0) faker (2.3.0) i18n (~> 1.6.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) ffi (1.11.1) figaro (1.1.1) thor (~> 0.14) friendly_id (5.2.5) activerecord (>= 4.0.0) globalid (0.4.2) activesupport (>= 4.2.0) hellosign-ruby-sdk (3.7.7) faraday mime-types multi_json honeybadger (4.5.2) htmlentities (4.3.4) i18n (1.6.0) concurrent-ruby (~> 1.0) image_processing (1.9.3) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.13, < 3) jaro_winkler (1.5.3) jbuilder (2.9.1) activesupport (>= 4.2.0) jmespath (1.4.0) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.2.0) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) kaminari-activerecord (= 1.1.1) kaminari-core (= 1.1.1) kaminari-actionview (1.1.1) actionview kaminari-core (= 1.1.1) kaminari-activerecord (1.1.1) activerecord kaminari-core (= 1.1.1) kaminari-core (1.1.1) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.7.0) launchy (~> 2.2) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) method_source (0.9.2) mime-types (3.3) mime-types-data (~> 3.2015) mime-types-data (3.2019.0904) mimemagic (0.3.3) mini_magick (4.9.5) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.11.3) monetize (1.9.2) money (~> 6.12) money (6.13.4) i18n (>= 0.6.4, <= 2) money-rails (1.13.2) activesupport (>= 3.0) monetize (~> 1.9.0) money (~> 6.13.2) railties (>= 3.0) msgpack (1.3.1) multi_json (1.13.1) multipart-post (2.1.1) nio4r (2.5.1) nokogiri (1.10.4) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) parallel (1.17.0) parser (2.6.4.1) ast (~> 2.4.0) pg (1.1.4) phone (1.2.3) poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) premailer (1.11.1) addressable css_parser (>= 1.6.0) htmlentities (>= 4.0.0) premailer-rails (1.10.3) actionmailer (>= 3) premailer (~> 1.7, >= 1.7.9) pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) public_suffix (4.0.1) puma (4.1.1) nio4r (~> 2.0) rack (2.0.7) rack-protection (2.0.7) rack rack-proxy (0.6.5) rack rack-test (1.1.0) rack (>= 1.0, < 3) rails (6.0.0) actioncable (= 6.0.0) actionmailbox (= 6.0.0) actionmailer (= 6.0.0) actionpack (= 6.0.0) actiontext (= 6.0.0) actionview (= 6.0.0) activejob (= 6.0.0) activemodel (= 6.0.0) activerecord (= 6.0.0) activestorage (= 6.0.0) activesupport (= 6.0.0) bundler (>= 1.3.0) railties (= 6.0.0) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) actionview (>= 5.0.1.x) activesupport (>= 5.0.1.x) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) railties (6.0.0) actionpack (= 6.0.0) activesupport (= 6.0.0) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) rainbow (3.0.0) rake (13.0.0) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) redis (4.1.3) regexp_parser (1.6.0) responders (3.0.0) actionpack (>= 5.0) railties (>= 5.0) rspec (3.8.0) rspec-core (~> 3.8.0) rspec-expectations (~> 3.8.0) rspec-mocks (~> 3.8.0) rspec-core (3.8.2) rspec-support (~> 3.8.0) rspec-expectations (3.8.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-mocks (3.8.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-rails (4.0.0.beta2) actionpack (>= 4.2) activesupport (>= 4.2) railties (>= 4.2) rspec-core (~> 3.8) rspec-expectations (~> 3.8) rspec-mocks (~> 3.8) rspec-support (~> 3.8) rspec-retry (0.6.1) rspec-core (> 3.3) rspec-support (3.8.2) rubocop (0.74.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.6) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) rubocop-performance (1.4.1) rubocop (>= 0.71.0) rubocop-rails (2.3.2) rack (>= 1.1) rubocop (>= 0.72.0) ruby-progressbar (1.10.1) ruby-vips (2.0.16) ffi (~> 1.9) ruby_dep (1.5.0) rubyzip (1.3.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.2.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) sprockets-rails tilt scenic (1.5.1) activerecord (>= 4.0.0) railties (>= 4.0.0) selenium-webdriver (3.142.6) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) shoulda-matchers (4.1.2) activesupport (>= 4.2.0) sidekiq (6.0.0) connection_pool (>= 2.2.2) rack (>= 2.0.0) rack-protection (>= 2.0.0) redis (>= 4.1.0) simplecov (0.17.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) slack-notifier (2.3.2) spring (2.1.0) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) thor (0.20.3) thread_safe (0.3.6) tilt (2.0.9) timecop (0.9.1) turbolinks (5.2.0) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (1.2.5) thread_safe (~> 0.1) unicode-display_width (1.6.0) uniform_notifier (1.13.0) warden (1.2.8) rack (>= 2.0.6) web-console (4.0.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) webdrivers (4.1.2) nokogiri (~> 1.6) rubyzip (~> 1.0) selenium-webdriver (>= 3.0, < 4.0) webpacker (4.0.7) activesupport (>= 4.2) rack-proxy (>= 0.6.1) railties (>= 4.2) websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.1.10) PLATFORMS ruby DEPENDENCIES allowable (~> 1.1.0) aws-sdk-s3 better_errors binding_of_caller bootsnap (>= 1.4.5) bootstrap-email bullet (~> 6.0.2) byebug capybara (~> 3.29.0) capybara-screenshot (~> 1.0.23) cocoon (~> 1.2.14) database_cleaner (~> 1.7.0) devise (~> 4.7.1) devise_invitable (~> 2.0.1) doorkeeper (~> 5.2.2) dropybara (~> 1.0.0) factory_bot_rails (~> 5.0.2) faker (~> 2.3.0) figaro (~> 1.1.1) friendly_id (~> 5.2.5) hellosign-ruby-sdk (~> 3.7.7) honeybadger (~> 4.5) image_processing (~> 1.9.3) jbuilder (~> 2.9.1) jquery-rails (~> 4.3.5) kaminari (~> 1.1.1) letter_opener (~> 1.7.0) listen (>= 3.1.5, < 3.2) mini_magick (~> 4.9.5) money-rails (~> 1.13.2) pg (>= 0.18, < 2.0) phone (~> 1.2.3) poltergeist (~> 1.18.1) pry (~> 0.12.2) puma (~> 4.1.1) rails (~> 6.0.0) rails-controller-testing (~> 1.0.4) rspec (~> 3.8.0) rspec-rails (~> 4.0.0.beta2) rspec-retry (~> 0.6.1) rubocop (~> 0.74.0) rubocop-performance (~> 1.4.1) rubocop-rails (~> 2.3.2) sass-rails (~> 6.0.0) scenic (~> 1.5.1) selenium-webdriver (~> 3.142.6) shoulda-matchers (~> 4.1.2) sidekiq (~> 6.0.0) simplecov (~> 0.17.1) slack-notifier spring (~> 2.1.0) spring-watcher-listen (~> 2.0.1) timecop (~> 0.9.1) turbolinks (~> 5.2.0) warden (~> 1.2.8) web-console (>= 4.0.1) webdrivers (~> 4.1.2) webpacker (~> 4.0.7) RUBY VERSION ruby 2.5.0p0 BUNDLED WITH 2.0.2 ```