From: Andrew Walrond Date: 2003-11-26T08:13:25+09:00 Subject: Re: Library path relative to current .rb file On Tuesday 25 Nov 2003 10:43 pm, Andrew Walrond wrote: > On Tuesday 25 Nov 2003 8:53 pm, Gavin Sinclair wrote: > > On Wednesday, November 26, 2003, 5:59:45 AM, Andrew wrote: > > > On Tuesday 25 Nov 2003 9:21 am, Gavin Sinclair wrote: > > >> require 'pathname' > > >> dir = Pathname.new(File.expand_path(__FILE__)).realpath > > Even better, > > dir = Pathname.new(__FILE__).expand_path.realpath Actually, this appears to be broken when I try to use it. Example: root@bob root # ls -l /sbin/rubyx lrwxrwxrwx 1 root root 23 Nov 24 20:41 /sbin/rubyx -> /pkg/rubyx.1/sbin/rubyx root@bob root # irb irb(main):001:0> require 'pathname' => true irb(main):002:0> Pathname.new('/sbin/rubyx') => # irb(main):003:0> Pathname.new('/sbin/rubyx').realpath Errno::ENOENT: No such file or directory - /sbin/pkg from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:144:in `lstat' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:144:in `realpath_rec' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:125:in `scan' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:125:in `realpath_rec' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:149:in `realpath_rec' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:125:in `scan' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:125:in `realpath_rec' from /pkg/ruby.1/lib/ruby/1.8/pathname.rb:113:in `realpath' from (irb):3 from :0 irb(main):004:0>