dry-rb/dry-system-rails

Weird behaviour when rake task is performed

blelump opened this issue · 1 comments

Hi @solnic ,

just got into strange issue while running rake db:migrate and I am not sure what may cause this. Look below:

$ rake db:migrate

rake aborted!
LocalJumpError: no block given (yield)
.rvm/gems/ruby-2.2.4@isa/gems/dry-system-rails-0.0.1/lib/dry/system/rails.rb:50:in `finalize!'
.rvm/gems/ruby-2.2.4@isa/gems/railties-4.2.5/lib/rails/railtie.rb:194:in `public_send'
.rvm/gems/ruby-2.2.4@isa/gems/railties-4.2.5/lib/rails/railtie.rb:194:in `method_missing'

which is essentially caused by namespace method name.

method(:namespace).source_location
=> [".rvm/gems/ruby-2.2.4@isa/gems/rake-10.5.0/lib/rake/dsl_definition.rb", 141]

whereas being in finalize! method:

self.class.instance_methods(false)
=> [:namespace, :finalize!, :name, :container]

Do you have any ideas what may cause this? Method name change fixes it, obviously.

I've probably found the underlying issue. Railtie extends Rake::DSL here and hence overrides the namespace method. Being in Railtie#run_tasks_blocks:

p method(:namespace).source_location if self.respond_to?(:namespace)
=> ["gems/ruby-2.2.4@isa/gems/dry-system-rails-0.0.1/lib/dry/system/rails.rb", 42]

The easiest fix would be to change the method name. What do you think @solnic ?