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
NoMethodError: undefined method `active_job' for Rails::Application::Configuration #35782
Comments
active_job is not an optional dependency. We don't support to comment the railtie since other framework depend on it. |
Actually, while it is not optional right now, I think it could be. @matthewd do you remember why we didn't make active job optional? |
Hi |
This absolutely is a bug to introduce a breaking change in a patch version of Rails. Further, it is preposterous to think that ActiveJob is a required framework. Sure, all of the apps you work on may have a good use case for queued background work, but that just means you're an expert in a particular niche. |
Hello, I don't think it was really @rafaelfranca or any contributors intention to introduce a breaking change in a patch release. This is an unintentional side effect of merging 44133fd in ... But yeah, as @rafaelfranca pointed out — we didn't make Active Job as an optional dependency, but it just happen to be that you could exclude Active Job and the app was still working. So, given that (1) you could use Rails without Active Job before 2.5.3 (2) Active Job is not a declared dependency on railtie gem, I think I'm leaning toward fixing that code to be this: if config.respond_to?(:active_job)
queue_adapter = config.active_job.queue_adapter
ActiveSupport.on_load(:active_job) do
self.queue_adapter = :inline
end
end That way we can allow people to still use Rails without Active Job and not introduce an unintended regression as a stop gap. Then, we can properly introduce a test and documentation to sanction that Rails app can run without Active Job if you choose to do so in the future versions. What do you think about my proposal? (I really wish we found out about this during RC period ... T_T) |
@sikachu, I was considering something like this: def load_seed
seed_file = paths["db/seeds.rb"].existent.first
return unless seed_file
if config.respond_to?(:active_job)
with_inline_jobs { load(seed_file) }
else
load(seed_file)
end
end |
I'd keep the conditional closer to the usage. @jlw do you want to open a PR? |
@rafaelfranca - sure, I'd love to put together a PR on this - but this is my first time working on Rails directly and I imagine it will be Monday at the earliest. |
@rafaelfranca Active Job is optional -- but it's a required dependency of Action Mailer (and Active Storage, I imagine, thought that seems to be missing the gem dep? cc @georgeclaghorn). It's required there, even if you don't want to do the work in a separate process, because AJ is the abstraction layer you use to express that preference (by using the inline adapter). Commenting out the railtie is definitely supposed to work -- if you do that and then use actionmailer, it'll require it for you. We should probably add some railties tests that do a basic generate-setup-and-boot with every combination of frameworks commented, in hope of catching this sort of thing... though as the main integration point with all the frameworks coming together, it's always going to be the hardest part to effectively cover. |
@matthewd or @rafaelfranca - I am having trouble creating test that fails either on master or on the |
First thing I see is that you are testing in the wrong file. Engine.rb is for rails engines, you should be testing in the app. But other than that I'd expect that to fail. Maybe the application that is being booted is not the one were you removed the active job railtie? |
@rafaelfranca - two things: First, the bug was introduced in Second, I was hoping that this change would be applied to any future Rails 5.2 bug fix releases. I made use of a modified version of the test file's |
[#35782] Allow loading seeds without ActiveJob (~> 5.2.3)
In #8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
In 8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
Hello, This change has caused my seeds to execute jobs that do not execute under rails 5.2.2. I use delayed job, and in my seeds I create some data, and then move long running tasks (like api requests) onto the queue. This change has forced these jobs to begin executing immediately. I have one project that relies on this backgrounding to do several long tasks in parallel, and another that utilizes delayed job to clear specific jobs from the db (this issue has surfaced because that project uses webmock to make sure seeds don't hit external APIs). On top of that, if in db/seeds.rb I inspect the current queue adapter via I am still trying to wrap my head around the root issue above. Perhaps if this is entirely a work around of not calling active job if it isn't there, perhaps the check should be simply to check if it is there, and to utilize whatever queue adapter is already set instead of forcing inline. |
Apparently this is required to be loaded: rails/rails#35782
[#35782] Allow loading seeds without ActiveJob (~> 5.2.3)
Hi folks, is there a timetable for the next patch release for Rails 5.2? Apparently, this regression has been fixed. Without it, our seeding is completely broken, which is a nuisance. 😉 |
In #8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
In #8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
In #8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
and accept sqlite3 version from env to support rails 6
In #8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
In #8bc80cf, we needed to add `active_job` to the dependencies to allow database seeding to continue to work. This was raised in rails/rails#35782 and fixed in rails/rails@d3dc651
Steps to reproduce
I have an app where I do not need Active Job, so its commented at application.rb:
In last version of rails 5.2.3 errors appear every time I ran: bundle exec rake db:setup.
I believe it is because this commit:
44133fd
Expected behavior
When require is not commented:
Loading development environment (Rails 5.2.3)
[1] pry(main)> Rails.application.config.active_job.queue_adapter
=> :async
Actual behavior
When require is commented:
System configuration
Rails version:
5.2.3
Ruby version:
2.5.1
The text was updated successfully, but these errors were encountered: