From: Glenn Jackman Date: 2010-09-15T02:35:08+09:00 Subject: Re: How does one get an absolute absolute file path? At 2010-09-14 11:35AM, "James Byrne" wrote: > Robert Dober wrote: > > On Tue, Sep 14, 2010 at 5:05 PM, James Byrne > > wrote: > >> > >> > >> /home/me/projects/tmp/testing/lib/library > >> > >> which fails because there is no /home/me/projects/tmp/testing/lib > >> directory. > >> > >> My question is: Is there any way to obtain the absolute path for > >> __FILE__ such that it returns the path to its actual location and not > >> one that includes any logical links? > > > > File.expand_path( File.dirname( __FILE__ )) > > normally does the trick for me. > > > > HTH > > R. > > This construction returns the logical link as part of the path. I want > the actual file system path to the script ignoring the logical link. By "logical link" I assume you mean symbolic link -- I've never heard of a logical link. You want the pathname package: require 'pathname' path = Pathname.new(__FILE__) p path.realpath -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous