From: James Britt Date: 2007-01-16T08:49:15+09:00 Subject: Re: Q: How can a Rake task know the caller's directory? Mike Harris wrote: > James Britt wrote: > >> 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. I've hacked ruby apps in this manner before, but they are prone to "gem update " stomping. So any mods to rake itself have to happen via by a plugin that will survive library updates. > > 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. > Too hackish, even for me. I'd rather see about a cleaner way for any arbitrary rake task to know the initial calling directory. -- James Britt "I have the uncomfortable feeling that others are making a religion out of it, as if the conceptual problems of programming could be solved by a single trick, by a simple form of coding discipline!" - Edsger Dijkstra