Wrapping ruby into one directory

Discussion in 'Ruby' started by Cary Fitzhugh, Nov 3, 2008.

  1. Hello --

    We're looking at using ruby on a product and I had a question about how to package up the ruby interpreter into one
    stand-alone directory.

    We'd like to have a full ruby interpreter which is not installed on the device. So that the interpreter can be
    downloaded on the fly with the ruby scripts, run, and then potentially discarded at a later time.

    Almost like ruby2exe but i don't want an exe since we're a linux box. I just want a direectory tree which has the
    interpreter and all it's ruby libs, etc. inside.

    say the ruby interpreter is in /data/bin/ruby/....
    and i have a script foo.rb. I could just run ./data/bin/ruby foo.rb and have this ruby interpreter run.
    That same directory could be located in /data/bin/ruby/XXXX/ or in another totally different directory as well.

    I can include ruby gems by including the gem/lib directory.
    But how do I connect the ruby interpreter with it's /lib/ruby/1.8/... stuff?

    Is that directory hardcoded somewhere in the binary?

    Sorry I'm not explaining this concept very clearly.

    Thanks for any hints. If this has been discussed before please give me some keywords to search the archive for. I
    couldn't find anything when I searched.

    Thanks,
    Cary
    Cary Fitzhugh, Nov 3, 2008
    #1
    1. Advertising

  2. Cary Fitzhugh wrote:
    > Hello --
    >
    > We're looking at using ruby on a product and I had a question about
    > how to package up the ruby interpreter into one stand-alone directory.
    >
    > We'd like to have a full ruby interpreter which is not installed on
    > the device. So that the interpreter can be downloaded on the fly with
    > the ruby scripts, run, and then potentially discarded at a later time.
    >
    > Almost like ruby2exe but i don't want an exe since we're a linux box.
    > I just want a direectory tree which has the interpreter and all it's
    > ruby libs, etc. inside.
    >
    > say the ruby interpreter is in /data/bin/ruby/....
    > and i have a script foo.rb. I could just run ./data/bin/ruby foo.rb
    > and have this ruby interpreter run.
    > That same directory could be located in /data/bin/ruby/XXXX/ or in
    > another totally different directory as well.
    >
    > I can include ruby gems by including the gem/lib directory.
    > But how do I connect the ruby interpreter with it's /lib/ruby/1.8/...
    > stuff?
    >
    > Is that directory hardcoded somewhere in the binary?
    >
    > Sorry I'm not explaining this concept very clearly.
    >
    > Thanks for any hints. If this has been discussed before please give
    > me some keywords to search the archive for. I couldn't find anything
    > when I searched.
    >
    > Thanks,
    > Cary
    >


    I have never used it, but rubyscript2exe is supposed to work on Linux.

    -Justin
    Justin Collins, Nov 4, 2008
    #2
    1. Advertising

  3. Cary Fitzhugh

    Robert Dober Guest

    As long as you install from source that should not be a problem, I
    have done it before to carry my Ruby with me on a thumbdrive.*

    When you do
    /configure --help
    you will see a lot of different options, but if IIRC, all you have to do is

    /configure --prefix=3D/myspecial/dir

    And you can call your ruby with a full path then.

    HTH
    Robert
    --=20
    C'est v=E9ritablement utile puisque c'est joli.

    Antoine de Saint Exup=E9ry
    Robert Dober, Nov 4, 2008
    #3
  4. Thanks.

    Can I move /myspecial/dir to /mynewspcial/dir/45 and it still runs just fine?

    Doesn't this hard-code the locations of those files into the binary somewhere? I mean, ruby needs to know where to look
    for it's /site/1.8 libs... is that hardcoded, or is it possible that that is a relative path... how cool would that be.
    I guess I have the source so I could change that. Anyone have any idea where in the ruby source it puts that value?

    Thanks,
    Cary

    Robert Dober wrote:
    > As long as you install from source that should not be a problem, I
    > have done it before to carry my Ruby with me on a thumbdrive.*
    >
    > When you do
    > ./configure --help
    > you will see a lot of different options, but if IIRC, all you have to do is
    >
    > ./configure --prefix=/myspecial/dir
    >
    > And you can call your ruby with a full path then.
    >
    > HTH
    > Robert
    Cary Fitzhugh, Nov 4, 2008
    #4
  5. Cary Fitzhugh

    Robert Dober Guest

    On Tue, Nov 4, 2008 at 6:48 PM, Cary Fitzhugh <> wrote:
    > Thanks.
    >
    > Can I move /myspecial/dir to /mynewspcial/dir/45 and it still runs just
    > fine?

    I do not think so, but why not try?
    >
    > Doesn't this hard-code the locations of those files into the binary
    > somewhere? I mean, ruby needs to know where to look for it's /site/1.8
    > libs... is that hardcoded, or is it possible that that is a relative path...
    > how cool would that be.

    I do not know, I just tried it ;)
    Robert Dober, Nov 4, 2008
    #5
  6. I also found in ruby.c: ruby_init_loadpath()

    If I wanted to really make things locked down, I guess that I could change that to not use any hardcoded paths, and just
    make everything relative to the location of the binary. add the binary directory/../lib/.....

    I think that might work - any comments?

    Cary


    Robert Dober wrote:
    > As long as you install from source that should not be a problem, I
    > have done it before to carry my Ruby with me on a thumbdrive.*
    >
    > When you do
    > ./configure --help
    > you will see a lot of different options, but if IIRC, all you have to do is
    >
    > ./configure --prefix=/myspecial/dir
    >
    > And you can call your ruby with a full path then.
    >
    > HTH
    > Robert
    Cary Fitzhugh, Nov 4, 2008
    #6
    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. Tom the Canuck

    Wrapping C code into a C++ object

    Tom the Canuck, Dec 3, 2005, in forum: C++
    Replies:
    10
    Views:
    1,247
    Jonathan Mcdougall
    Dec 5, 2005
  2. Joe Kovac
    Replies:
    2
    Views:
    329
    bruce barker
    Oct 11, 2007
  3. gw
    Replies:
    4
    Views:
    123
    Florian Gross
    Jan 1, 2005
  4. Scott Raymond
    Replies:
    4
    Views:
    123
    Devin Mullins
    Dec 23, 2005
  5. Replies:
    0
    Views:
    68
Loading...

Share This Page