Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing files in the same directory as script

I need to access files that are relative to the location of my Ruby script.

The only solution I've found is using File.dirname(__FILE__), however, if the script is run from a symlink, __FILE__ gives the location of the symlink.

I would prefer a solution that does not involve looking at __FILE__, checking if it's a link, if it is, finding out where it points to. But, if there is no other way, it would be nice to know if there is already a gem to do this?

like image 381
Jeffrey Aylesworth Avatar asked Feb 27 '23 21:02

Jeffrey Aylesworth


1 Answers

does File.expand_path help?

(don't have a 'nix box to try it on)

like image 102
AShelly Avatar answered Mar 07 '23 09:03

AShelly