J
James Byrne
I have a situation where I call a ruby script from a directory that is a
logical link to the actual one. So for instance the actual path is:
/home/me/projects/bin/script.rb
But the path used to call the script is
/home/me/projects/tmp/testing/bin/script.rb
where tmp/testing/bin is a logical link to projects/bin.
With Ruby-1.8.7 using a simple require in the script, like this, works
fine:
require File.dirname(__FILE__) + "../lib/library"
However, this no longer works in 1.9.2 because of the decision, asinine
in my opinion, to remove . from the default load path. So, what I am
trying to discover is how best to provide an absolute path which gives
the same result. The problem is that when I build such a path using
File.expand_path I end up with this:
/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?
logical link to the actual one. So for instance the actual path is:
/home/me/projects/bin/script.rb
But the path used to call the script is
/home/me/projects/tmp/testing/bin/script.rb
where tmp/testing/bin is a logical link to projects/bin.
With Ruby-1.8.7 using a simple require in the script, like this, works
fine:
require File.dirname(__FILE__) + "../lib/library"
However, this no longer works in 1.9.2 because of the decision, asinine
in my opinion, to remove . from the default load path. So, what I am
trying to discover is how best to provide an absolute path which gives
the same result. The problem is that when I build such a path using
File.expand_path I end up with this:
/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?