How to compile ruby to executable? (Linux)

T

Toni Tanskanen

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?
 
T

Toni Tanskanen

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

John Morrice

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

Toni Tanskanen

$ 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?
 
J

John Morrice

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
 
C

Charles Oliver Nutter

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top