Require and symbolic links

Discussion in 'Ruby' started by Zouplaz, Nov 9, 2008.

  1. Zouplaz

    Zouplaz Guest

    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 ?
     
    Zouplaz, Nov 9, 2008
    #1
    1. Advertising

  2. Zouplaz

    Stefan Lang Guest

    2008/11/9 Zouplaz <>:
    > 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
     
    Stefan Lang, Nov 9, 2008
    #2
    1. Advertising

  3. Zouplaz

    Zouplaz Guest

    le 09/11/2008 21:47, Stefan Lang nous a dit:

    >
    > 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.
    >


    Thanks, I'll give File.readlink a look - You're right about using an
    adequate packaging solution, except that the final user is me ;-) This
    is for a program that I often upgrade and which is runned on 2 machines
    having different directory structures - I would like to avoid the
    tedious task of modifying the source after every upgrade
     
    Zouplaz, Nov 10, 2008
    #3
  4. On Mon, Nov 10, 2008 at 6:47 AM, Zouplaz <> wrote:
    >
    > Thanks, I'll give File.readlink a look - You're right about using an
    > adequate packaging solution, except that the final user is me ;-) This is
    > for a program that I often upgrade and which is runned on 2 machines having
    > different directory structures - I would like to avoid the tedious task of
    > modifying the source after every upgrade


    There are projects like hoe that automate the creation of a gem for
    you - you could combine that with a rake task that installs the newly
    created gem on both your machines every time you make one.

    martin
     
    Martin DeMello, Nov 10, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim
    Replies:
    4
    Views:
    7,045
  2. Juha Laiho
    Replies:
    0
    Views:
    688
    Juha Laiho
    Jul 20, 2004
  3. Nick Howes
    Replies:
    6
    Views:
    577
    Toby A Inkster
    Nov 24, 2003
  4. pekka.niiranen
    Replies:
    0
    Views:
    274
    pekka.niiranen
    Feb 10, 2004
  5. Don McClean

    Rake::Filelist and symbolic links

    Don McClean, Jul 2, 2007, in forum: Ruby
    Replies:
    0
    Views:
    130
    Don McClean
    Jul 2, 2007
Loading...

Share This Page