-
Notifications
You must be signed in to change notification settings - Fork 179
Description
Hi everyone,
we’re encountering a SyntaxError on Ruby 3.3.x when running rake tasks (e.g. rails db:migrate) with ros-apartment 3.4.1.
Environment
ros-apartment: 3.4.1
Ruby: 3.3.0
Rails: 7.0.3 (also reproducible independently of Rails)
Error
Running either rails db:migrate or a plain Ruby syntax check fails:
bundle exec ruby -c lib/apartment/tasks/task_helper.rb
Gives this error
anonymous block parameter is also used within block (SyntaxError)
Problematic code
In lib/apartment/tasks/task_helper.rb:
def each_tenant_parallel(&) with_advisory_locks_disabled do case resolve_parallel_strategy when :processes each_tenant_in_processes(&) else each_tenant_in_threads(&) end end end
Ruby 3.3 raises a SyntaxError when an anonymous block parameter (&) is referenced inside another block.
Expected behavior
ros-apartment rake tasks should run correctly on Ruby 3.3, as Ruby 3.3 is officially released and widely adopted.
Suggested fix (syntax-only, no behavior change)
Rename the anonymous block parameter to an explicit one:
def each_tenant_parallel(&block) with_advisory_locks_disabled do case resolve_parallel_strategy when :processes each_tenant_in_processes(&block) else each_tenant_in_threads(&block) end end end
This change fixes the SyntaxError and preserves existing behavior.
Impact
Breaks db:migrate and other rake tasks on Ruby 3.3+
Affects production systems that rely on Apartment-based multitenancy
Not detectable until rake tasks are executed
Happy to submit a PR if you’d like
Thanks for maintaining the gem!