Comments (9)
OK, that is not good because middleware is not reloaded. In Rails 7 you won't be able to configure the provider (precisely, to avoid these situations). You should tell the autoloader to ignore lib/omni_auth
:
Rails.autoloaders.main.ignore("#{config.root}/lib/omni_auth")
and issue a require
call from the initializer.
Not saying this solves the whole situation, but for starters it fixes something.
from zeitwerk.
I need to read this with some time, but let me ask a couple of questions:
- Who defines
OmniAuth::Strategies::ShieldOIDC
? - The
provider
call in the initializer is setting up Rack middleware, right?
from zeitwerk.
Hello Xavier, thank you.
- It is a custom strategy within our repository.
- Yes, this is my understanding of how omniauth works.
from zeitwerk.
Is OmniAuth::Strategies::ShieldOIDC
defined in a directory that belongs to the autoload paths?
from zeitwerk.
It is defined in lib/omni_auth/strategies/shield_oidc.rb
, and the autoload paths from application.rb
are the following:
config.autoload_paths += %W[
#{config.root}/app/models/serializable
#{config.root}/app/models/concerns
#{config.root}/lib
#{config.root}/demo
#{config.root}/qa
#{config.root}/app/mailers/concerns
]
from zeitwerk.
I have a workaround, but it doesn't seem the right. I added the following require statements (with the specific order, so that when application_record
is loaded the two dependencies have already been loaded). I also removed the reference to the Member
constant in my lib/shield_settings.rb
.
# config/initializers/omniauth.rb
# ... other require statements
require "concerns/fine_grained_validations"
require "concerns/policy_scope_support"
require "application_record"
If you have any other insights, I will appreciate it if you chime in. Thank you.
from zeitwerk.
OK, we need to polish a bit more.
No reloadable code should be loaded while the application is booting. The file lib/shield_settings.rb
is still reloadable, because lib
is in the autoload paths. Since the middleware uses the contants defined there, you need to tell the autoloader this file has to be ignored as well:
Rails.autoloaders.main.ignore("#{config.root}/lib/shield_settings.rb")
Let's iterate until we reach a more controlled setup to address the issue with the migrations.
Ideally, no warning should be issued. This section of the upgrdading guide has some tips, but I am here to help you anyway ❤️.
from zeitwerk.
Since this is something related to how the Rails application is configured, I have moved the issue to the Rails repository (rails/rails#49310).
from zeitwerk.
I am pretty sure that the connection closed issue is fixed by rails/rails#45450 but it can't be backported to 7-0-stable because it's too big of a change in internal behavior. Upgrading to 7.1.x should fix that particular issue.
from zeitwerk.
Related Issues (20)
- Zeitwerk not loading children of struct namespaces HOT 5
- Zeitwerk not autoload the middleware directory HOT 2
- (Re-)Loading modules defined as a root namespace HOT 2
- Ruby 3.3.0-rc1 warning issues HOT 3
- Gemfile/gemspec csv HOT 2
- Getting the source location of a constant while loading it HOT 12
- Gem's loader is being setup multiple times HOT 24
- Autoloading not working in rake task HOT 4
- Zeitwerk::NameError on calling Zeitwerk::Loader.eager_load_all HOT 11
- Deprecation message coming from zeitwerk HOT 2
- Reloading of local gems HOT 27
- drb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0 HOT 3
- Ruby 3.4.0 no longer includes "abbrev" and it suggests zeitwerk to include it HOT 2
- Error when using in Ractor HOT 3
- Namespaced concerns don't load HOT 33
- Zeitwerk::NameError for gem VERSION HOT 8
- Add CHANGELOG.md to gem HOT 3
- `eager_load` clobers previous `eager_load_dir` and `load_file` calls? HOT 6
- In Rails, `app/jobs/seeder/` directory breaks `db:seed` task HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zeitwerk.