Causes exception when you have a model called Task #8

Closed
JurgenJocubeit opened this Issue Jul 18, 2012 · 9 comments

Comments

Projects
None yet
2 participants

I have a rails application that has Project and Task models. I'm using seedbank to seed the development environment. Seeding works beautifully when I don't want to seed the Task model or indeed instantiate a Task model anywhere.

WARNING: Deprecated reference to top-level constant 'Task' found at: 
    Use --classic-namespace on rake command
    or 'require "rake/classic_namespace"' in Rakefile
ArgumentError: wrong number of arguments (0 for 2)
    from /Users/Dom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:71:in `initialize'
    from (irb):1:in `new'
    from (irb):1
    from /Users/Dom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
    from /Users/Dom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
    from /Users/Dom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

It seems to think I'm trying to instantiate a new Rake Task. If I remove seedbank from the gem file, everything works fine.
I can't see the problem after looking at the seedbank code, it seems to be namespaced properly, and it doesn't make sense to me that a module would get confused with a class. But anytime I try t = Task.new with seedbank in my gemfile I get this exception.

Owner

james2m commented Jul 18, 2012

This looks fun! Any chance you can drop me a sample app or at least the Gemfile and enough of your task model to recreate the problem?

Okay that was not much fun. I built a minimal app with seedbank and couldn't replicate the issue. My thoughts then were that it had something to do with the load order in the Gemfile. My colleague and I then spent most of the day tracking down the offending gems by changing the order in which they appear in the Gemfile. We have some big projects with lots of dependencies, but we managed to narrow it down to 4 offenders. What they have in common I'm not sure at this stage but loading any of those 4 before seedbank will throw the reported exception. My instincts tell me it has something to do with extending Rake::Task.

The four gems that cause the problem for me are: pg_search, periscope-activerecord, ancestry and client_side_validations.

I have confirmed this by adding those 4 gems to the minimal test project, and have tested each one separately. I have checked in the project for you to play with. The instructions for replicating the issue are in the readme. The project is at https://github.com/MeetDom/seedbank_projects.

For now, we're happy to have seedbank loaded before these 4 gems, but I'm nervous about the future and what's at the root of the problem... you just never know when any other gem might exhibit the same behavior.

Also, you'll note that none of those gems are actually implemented for their functionality in the models or app anywhere, they're simple loaded and present in the Gemfile.

Owner

james2m commented Jul 18, 2012

Thanks for putting all that together. I'll see what I can find.

@james2m james2m closed this in d757987 Jul 19, 2012

Owner

james2m commented Jul 19, 2012

Thanks for all your help. That was pretty easy to fix in the end thanks to all your hard work. Please update to v0.1.2.

Thanks heaps for sorting this... and sharing seedbank.

Owner

james2m commented Jul 19, 2012

My pleasure.

Just so you know, the date reported for the latest version (v0.1.2) at Rubygems.org is Mar 13, 2012... the seedbank.gemspec needs to be updated.

Owner

james2m commented Jul 19, 2012

Oops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment