How to compile ruby to executable? (Linux)

Discussion in 'Ruby' started by Toni Tanskanen, Dec 17, 2010.

  1. Hi, everyone!

    I'm wondering how I could compile my .rb file to executable? I know that
    there's rubyscript2exe and allinoneruby but I have problem using them.
    When I type "rubyscript2exe" or "allinoneruby" to command line, it says
    "command not found".

    I installed both with rubygems.

    Can anyone help me with this?

    --
    Posted via http://www.ruby-forum.com/.
     
    Toni Tanskanen, Dec 17, 2010
    #1
    1. Advertising

  2. When I put...

    ruby /var/lib/gems/1.8/gems/rubyscript2exe-0.5.3/lib/rubyscript2exe.rb
    /textinput.rb

    ...it doesn't make executable file...

    --
    Posted via http://www.ruby-forum.com/.
     
    Toni Tanskanen, Dec 17, 2010
    #2
    1. Advertising

  3. Toni Tanskanen

    John Morrice Guest

    On Fri, 17 Dec 2010 21:54:32 +0900
    Toni Tanskanen <> wrote:

    > Hi, everyone!
    >
    > I'm wondering how I could compile my .rb file to executable? I know
    > that there's rubyscript2exe and allinoneruby but I have problem using
    > them. When I type "rubyscript2exe" or "allinoneruby" to command line,
    > it says "command not found".
    >
    > I installed both with rubygems.
    >
    > Can anyone help me with this?
    >


    Can you run other programs you have installed with rubygems?

    Perhaps they are not in your PATH.

    In a shell do:

    $ locate allinoneruby | grep bin

    To see if you can find where the program is installed.

    Then do:

    $ echo $PATH

    to see your path. Is that directory on the list?

    If not then you need to

    export PATH="/path/to/gem/bin/dir:$PATH"

    in your .bashrc, or whatnot.

    Note:
    On my system, ruby executables are installed to /usr/local/bin.

    Another note: I have no experience with these particular gems - this is
    just what I would normally do when I have this sort of problem.
     
    John Morrice, Dec 17, 2010
    #3
  4. $ locate allinoneruby | grep bin

    That gives nothing, but I know that it's in this directory:

    /var/lib/gems/1.8/gems/rubyscript2exe-0.5.3/bin

    And no I haven't other executable programs installed with gem.

    I did that export with "/var/lib/gems/1.8/bin" directory but now I get
    following error message when trying to compile:

    /var/lib/gems/1.8/gems/allinoneruby-0.2.11/bin/allinoneruby:5:in
    `replace': can't modify frozen string (TypeError)
    from /var/lib/gems/1.8/gems/allinoneruby-0.2.11/bin/allinoneruby:5
    from /var/lib/gems/1.8/bin/allinoneruby:19:in `load'
    from /var/lib/gems/1.8/bin/allinoneruby:19

    How I can take away that directory from $PATH?

    --
    Posted via http://www.ruby-forum.com/.
     
    Toni Tanskanen, Dec 17, 2010
    #4
  5. Toni Tanskanen

    John Morrice Guest

    > I did that export with "/var/lib/gems/1.8/bin" directory but now I
    > get following error message when trying to compile:
    >
    > /var/lib/gems/1.8/gems/allinoneruby-0.2.11/bin/allinoneruby:5:in
    > `replace': can't modify frozen string (TypeError)
    > from /var/lib/gems/1.8/gems/allinoneruby-0.2.11/bin/allinoneruby:5
    > from /var/lib/gems/1.8/bin/allinoneruby:19:in `load'
    > from /var/lib/gems/1.8/bin/allinoneruby:19
    >
    > How I can take away that directory from $PATH?


    Why would you want to remove that directory from your PATH?

    If you do, then next time you want to run a gem, you'd need to repeat
    this process.

    But if you insist, then just remove the export statement from
    your .bashrc and open a new shell and it should be back to its usual,
    non-gem running self.

    As I said, I don't use any of those ruby compilers, so unfortunately I
    can't help you with your error there.

    John
     
    John Morrice, Dec 17, 2010
    #5
  6. Toni Tanskanen, Dec 17, 2010
    #6
  7. Toni Tanskanen

    John Morrice Guest

    John Morrice, Dec 17, 2010
    #7
  8. On Fri, Dec 17, 2010 at 8:22 AM, John Morrice <> wrote:
    >> Is there other compilers than these then?

    >
    > There's a JRuby compiler that I've never used
    > http://kenai.com/projects/jruby/pages/JRubyCompiler
    >
    > But that compiles to java class files, rather than linux executables.


    And rawr makes Linux, OS X, and Windows executables out of JRuby programs.

    http://rawr.rubyforge.org/
     
    Eric Christopherson, Dec 18, 2010
    #8
  9. On Sat, Dec 18, 2010 at 9:49 AM, Eric Christopherson
    <> wrote:
    > On Fri, Dec 17, 2010 at 8:22 AM, John Morrice <> wrote:
    >>> Is there other compilers than these then?

    >>
    >> There's a JRuby compiler that I've never used
    >> http://kenai.com/projects/jruby/pages/JRubyCompiler


    There's generally two reasons to compile Ruby to JVM bytecode ahead of time:

    * To hide the code
    * To create a "normal" Java class

    Neither are necessary to bundle Ruby code into a single executable jar
    or exe, as Eric mentions that rawr (and now warbler) can do.

    >> But that compiles to java class files, rather than linux executables.

    >
    > And rawr makes Linux, OS X, and Windows executables out of JRuby programs.
    >
    > http://rawr.rubyforge.org/


    Rawr is a great option, if a bit undermaintained. Nick Sieger's
    warbler can also take an arbitrary project/app/lib and bundle it into
    an executable .jar file. Then you just need Java installed somewhere,
    which is generally pretty easy.

    - Charlie
     
    Charles Oliver Nutter, Dec 18, 2010
    #9
    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. Ruslan Spivak
    Replies:
    0
    Views:
    426
    Ruslan Spivak
    Jul 15, 2003
  2. =?ISO-8859-1?Q?Gerhard_H=E4ring?=

    Re: how to compile python program to linux executable

    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 15, 2003, in forum: Python
    Replies:
    0
    Views:
    520
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=
    Jul 15, 2003
  3. sreekant
    Replies:
    0
    Views:
    426
    sreekant
    Jul 18, 2003
  4. Nagaraj
    Replies:
    1
    Views:
    924
    Lionel B
    Mar 1, 2007
  5. King
    Replies:
    2
    Views:
    693
Loading...

Share This Page