Rake tasks inside gem not being found

2019-03-02 05:02发布

问题:

I have implemented what edebill suggested in his answer to this question.

If I point to the gem in the usual way, with it installed in my environment

gem 'activerecord_datawarehouse'

rake -T does not show my rake tasks, but if I point directly to the gem source code, like

gem 'activerecord_datawarehouse', :path => "/home/acras/code/activerecord_datawarehouse"

It shows and rake tasks work perfectly.

What could I be missing here? I did double checked and the installed gem is the same that I have in the source code.

回答1:

Fixed it on my end. In the gemspec, you need to include the rake tasks files as well, not just the lib files:

Instead of:

  s.files = Dir['lib/**/*.rb']

Use:

  s.files = Dir['lib/**/*.rb'] + Dir['tasks/*.rake']