- 1 year ago 72
Ruby Question

Can a Ruby script tell what directory it’s in?

Inspired by "Can a Bash script tell which directory it is stored in?", what's the Ruby way to do this?

Answer Source

File.dirname(__FILE__) will give you the path relative to the script being run. File.expand_path(File.dirname(__FILE__)) will give you the absolute path.