Rake `debug` cannot find `generate` within a namespace
Closed this issue · 3 comments
I namespace zenweb tasks since I have my own other tasks in my Rakefile, but the debug
task fails to find the generate
task:
❯ rake zenweb:debug
rake aborted!
NoMethodError: undefined method `generate' for nil:NilClass
.../zenweb-3.10.3/lib/zenweb/tasks.rake:193:in `block in <top (required)>'
Tasks: TOP => zenweb:debug
(See full trace by running task with --trace)
No, it can't call generate
on nil... Comes down to this:
task :debug => ".site" do
site = website
path = ENV['PAGE'] || ENV['F'] || ENV['FILE'] || "index.html.erb"
if path then
page = site.pages[path]
page.generate
I'm not sure why that first conditional is there, since it can't be falsey...
but it looks like it needs some extra guards around what happens when site.pages[path]
doesn't look up. Seems like you're asking for a file that doesn't exist?
So, on a guess, you're NOT trying to generate "index.html.erb"
as your top level file in your site at all... so this dies immediately? Try rake debug F=some_file.ext
and lemme know what happens.
I did just find a bug in the debug task wrt .site
not being wired up and am fixing that now.
OK. I've moved my website over to a namespaced set of tasks and confirmed that it does work fine. I've also improved the error so it tells you what went wrong.
I think this is not a bug and am closing. Please feel free to reopen if you think I missed something or have questions.