merit-gem / merit

Reputation engine for Rails apps
Other
1.53k stars 198 forks source link

DEPRECATION WARNING: Initialization autoloaded the constant Merit::Badge. #331

Closed burmashave closed 4 years ago

burmashave commented 5 years ago

Hello,

Just started a new app with Rails 6.0.0.rc1 (and Merit) and got a deprecation notice when running tests via rspec:

DEPRECATION WARNING: Initialization autoloaded the constant Merit::Badge.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload Merit::Badge, for example,
the expected changes won't be reflected in that stale Class object.

This autoloaded constant has been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.

There is some discussion about a similar notice here.

tute commented 5 years ago

Thanks for the report. I started a PR to test merit against Rails 6: https://github.com/merit-gem/merit/pull/334

EDIT: Warning appears in the log files

tute commented 4 years ago

I merged in code loading with zeitwerk in https://github.com/merit-gem/merit/pull/337. Should fix this issue, please let me know if it doesn't!

burmashave commented 4 years ago

Just tried using the latest commit with rails 6.0.3.1, but unfortunately I'm getting the same deprecation warning. Additionally, there are now some weird warnings related to the Thor gem:

Deprecation warning: Expected string default value for '--orm'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
Deprecation warning: Expected string default value for '--orm'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
Deprecation warning: Expected string default value for '--orm'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
DEPRECATION WARNING: Initialization autoloaded the constant Merit::Badge.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload Merit::Badge, for example,
the expected changes won't be reflected in that stale Class object.

This autoloaded constant has been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.

If you need more info, let me know! I'd like to help but this issue has me my

The Thor warnings display any time a rails command is used, e.g. rails routes, etc.

Switching back from: gem 'merit', git: 'https://github.com/merit-gem/merit'

to: gem 'merit, '3.0.3'

... gets rid of the Thor warnings, but leaves the notice about the autoloaded constant when running rspec.

Sorry! Let me know if you need any more info from me.

tute commented 4 years ago

Oh wow thanks! Will try to address it in about two weeks, when a project I'm working on winds down.

If you get to it before me I'll happily review. Thanks for sharing!