Rakefile "$0" path in rake

Is there a way to get the path to “itself” in a rakefile loaded by rake?

ie for:
rake --rakefile …/…/some/path/to/rakefile.rb


inside rakefile

myPath = # ???
p “running #{myPath}”

Peter Pk schrieb:

p “running #{myPath}”
try using the “magic variable” FILE ?

On Jan 13, 2009, at 8:57 AM, Peter Pk wrote:

Is there a way to get the path to “itself” in a rakefile loaded by
rake?

Sure.


inside rakefile

myPath = # ???

my_path = File.expand_path(FILE)

p “running #{myPath}”

Hope that helps.

James Edward G. II

badboy wrote:

Peter Pk schrieb:

p “running #{myPath}”
try using the “magic variable” FILE ?

Thanks! Thats it!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs