Full paths of Ruby interpreter and running script

Well the full path to the running script is easy enough to get from
within Ruby and based on your needs might suffice for finding the
configuration file at runtime.

puts File.expand_path(__FILE__) # c:/rubytest/test.rb

If you want just the directory then use this

puts File.dirname(File.expand_path(__FILE__)) # c:/rubytest

Hope this helps!



-----Original Message-----
From: Jamal Mazrui [mailto:Jamal.Mazrui@fcc.gov]
Sent: Monday, April 17, 2006 10:54 AM
To: ruby-talk ML
Subject: Full paths of Ruby interpreter and running script

I've looked through and experimented with predefined global constants,
but so far have not figured how to get the full path and name of the
Ruby interpreter and/or main script file from within a running program.
I want to distribute a program that can be installed in a folder chosen
by the user. The program would save configuration information in the
same folder. In order to find the configuration file at runtime, I
thought I would query the full path of the Ruby interpreter or script
file. In case it makes a difference, I'm using Windows.