pedromtavares/universitas

rake db:populate error - nil object when you didn't expect it

tmlee opened this issue · 4 comments

Is anyone getting an error running rake db:populate?

Successfully created group Expanded foreground middleware
Successfully created group Polarised regional groupware
Successfully created group Visionary solution-oriented installation
Successfully created group Profit-focused eco-centric data-warehouse
Successfully created group Reactive coherent moderator
Successfully created group Ergonomic heuristic knowledge base
rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

Although it doesnt halt anything. but was wondering if there were any data not getting created

Yes I am experiencing the same problem. I've identified the problem in populate.rake, will submit a fix shortly.

This has been corrected on master. My diagnosis is that there is a problem returning large data sets with MySQL during a rake task unless the MySQL Server has been configured a certain way (i.e. starting the server with --max_allowed_packet=4M should work here). The rails console does not exhibit this problem so it makes it particularly hard to diagnose and by default on OS X/brew it appears that the MySQL server runs without max_allowed_packet set, defaulting to 1M. To work around this I replaced User.all which was passing the 1M threshold with a chunking approach, breaking User.all into 10 separate queries, each returning 10 rows.

Yeah that solves it. Thanks!

@cfeduke
Damn, you're good.