Rake is great, but as far as error reporting goes, it could use some design aesthetics. Case in point, every so often, Rake decides to take a little nap:
stopping only thread note: use sleep to stop forever
So the “only thread” part makes sense, since I’m not running any multitask. But I don’t remember asking it to sleep, or for that matter take the eternal nap. All I did was to accidentally make a circular dependency.
So here’s a little hack you can use with Rake, to make it report a circular dependency:
class Rake::Task
def invoke()
fail "Circular dependency " + (stack + [name]).join(”=>”) if stack.include?(name)
@lock.synchronize do
puts “** Invoke #{name} #{format_trace_flags}” if application.options.trace
return if @already_invoked
begin
stack.push name
@already_invoked = true
invoke_prerequisites
execute if needed?
ensure
stack.pop
end
end
end
def invoke_prerequisites()
prerequisites.each { |n| application[n, @scope].invoke }
end
protected
def stack()
Thread.current[:rake_stack] ||= []
end
end
class Rake::MultiTask
def invoke_prerequisites()
threads = @prerequisites.collect do |p|
copy = stack.dup
Thread.new(p) { |r| stack.replace copy ; application[r].invoke }
end
threads.each { |t| t.join }
end
end
Now it will just say “Circular dependency foo=>bar=>foo”. It doesn’t fix your code, but at least you know what’s happening.
Another trick, not specific to Rake but still very useful for Rakefiles:
require "highline"
require "facet/module/alias_method_chain"
if PLATFORM =~ /linux|darwin|cywin/
module Kernel
def warn_with_color(message)
warn_without_color HighLine.new.color(message.to_s, :red)
end
alias_method_chain :warn, :color
end
end
It colors all your warnings red. Not on Windows, though, but then again …

