Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if frameworks are loaded too early #50133

Open
runephilosof-abtion opened this issue Nov 22, 2023 · 0 comments · May be fixed by #46047
Open

Warn if frameworks are loaded too early #50133

runephilosof-abtion opened this issue Nov 22, 2023 · 0 comments · May be fixed by #46047

Comments

@runephilosof-abtion
Copy link

If you use a gem that loads the Rails framework too early, you will get various problems.

Examples of issues that are caused by gems loading Rails incorrectly (from #46047 (comment))

Fixes to gems that loaded Rails too early

Pull requests that try to make Rails warn about this problem, when your Rails code has been loaded too early

This issue is here to track the efforts to fix this issue. It seems both above PRs are stalled.

Steps to reproduce

  # config/initializers/000_some_initializer.rb
  ActiveRecord::Base.configurations # Make use of AR::Base which hasn't been loaded yet

  # config/initializers/new_framework_defaults.rb
  Rails.application.config.active_record.collection_cache_versioning = false
  # Setting this configuration won't do anything since ActiveRecord::Base is already
  # loaded and the `set_configs` initializer has already iterated over application
  # config (see https://github.com/rails/rails/blob/b67785a476cf346b09f5ebc71b4d61aae3ac27b3/activerecord/lib/active_record/railtie.rb#L192)

  puts ActiveRecord::Base.collection_cache_versioning # true

Expected behavior

Rails would warn on stderr about this problem, or raise an error.
Extra points, if it could pinpoint (stacktrace?) what code is doing the wrong loading.

Actual behavior

Initializer configuration from new_framework_defaults of ActiveRecord is ignored.

System configuration

Rails version:
7.1.2
Ruby version:
2.7.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants