James Britt wrote:

> I'm increasingly using rake files for common system tasks.  Since Rake 
> will search up a directory tree until it finds a Rakefile, I can have 
> one in my home directory and call tasks from anyplace below that.
>
> But tasks that need to know something about the current directory have 
> me stymied.  Calling Dir.pwd in a task reflects the directory of the 
> Rakefile.
>
> Is there a rake method that returns the path of  where the Rakefile 
> search began?
>
>
> E.g., if I'm in /home/james/foo/bar, and the nearest Rakefile is in 
> /home/james, with task :whereami, and I call
>
>  $ rake whereami
>
> what does :whereami have to do to return '/home/james/foo/bar' ?
>
> Thanks!
>
Modify rake to log the initial working directory before doing anything 
else.  You could do this by putting the line to log the dir in the file 
bin/rake.  Take advantage of ruby's openness.

Alternatively, you could put a file in a dir on your PATH (let's say 
rake2) to log the dir and then delegate to rake, and just call rake2 
instead of rake from the command line.