From: Jim Weirich Date: 2007-01-16T12:02:53+09:00 Subject: Re: Q: How can a Rake task know the caller's directory? 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! task :whereami do puts Rake.original_dir end -- Jim Weirich -- Posted via http://www.ruby-forum.com/.