On Monday 24 January 2005 05:20 pm, itsme213 wrote:
> I came across a curious rake behavior, in which my rakefile required a file
> that (accidentally) required the rakefile itself.

Hmmm ... don't do that :)
> It makes rake execute tasks twice.

Yep.  Rake loads the rakefile via the "load" command, require doesn't know 
that the rake file is alread loaded.  So loading it and requiring it cause 
the file to be evaluated twice.  Rake tasks are additive, e.g. you can say:

  task :one do puts "ONCE" end
  task :one do puts "TWICE" end

Since the file is evaluated twice, each task action is added to the task 
twice.  Therefore running any task executes the actions twice.

If there is stuff in the rakefile that the other file depends on, it is better 
to extract it into a normal library file and let both the rakefile and the 
other file require that third file.

Hope this helps.

-- 
-- Jim Weirich    jim / weirichhouse.org     http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct, 
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)