2008/11/9 Zouplaz <user / domain.invalid>:
> Hi, thanks to the Shebang my /usr/local/somewhere/over/the/rainbow.rb get
> ruby interpretor launched automagically.
>
> BUT, because I need it very often I've created a /usr/local/bin/rainbow
> symlink to it.
>
> Now, the require in rainbow.rb no more finds the files in
> /usr/local/somewhere/over/the/lib directory. So, I used absolute path and
> it's fine, but francky I don't like absolute paths because anybody should be
> able to put and use rainbow.rb on any directory
>
> How can I do to have both this nice symlink without losing relative require

You could try to construct the "real" path with the help of
File.symlink? and File.readlink.

Personally, I wouldn't bother. There are a couple of install options
that, depending on the situation, make much more sense and
are less brittle:

1) If you want to make install convenient for other Ruby developers,
make a gem. (And if they don't like a gem they'll know how to unpack
it and scatter the files all over their harddrives anyway they please.)

2) If you want to distribute to Linux/Unix users in general, make
a deb or RPM or whatever package.

3) If you want to give the program to people who have little
computer knowledge, try RubyScript2Exe
(http://www.erikveen.dds.nl/rubyscript2exe/). That packs
everything into a single clickable executable.

Stefan