tags:

views:

81

answers:

2

I've got a project for work I'd like to do in Ruby that will have to run on Windows, but perturbing the filesystem for a Ruby install or RubyScript2Exe unpack isn't an option (this is supposed to be the harness for a testing system). Has anyone successfully used Crate to package up something on Windows? If so, what was your build environment like and can you pass on any other hints?

+1  A: 

Hello,

I've tried and worked in getting Crate work under Windows, but is a more complicated system than I would expect.

If extraction of code for your system is your problem. I recommend take a look to Exerb, and specially: exerb-mingw hosted on GitHub exerb-mingw

It will generate a single executable like Ocra or RubyScript2Exe, but with the difference that the source code will not be extracted and extensions will be dynamically loaded.

This works perfectly with RubyInstaller packages, and is being used with Pik (Ruby version manager for Windows).

Hope this helps.

Luis Lavena
I just looked through some of the c++ source for exerb, and it seems to also create tempfiles, at least for compiled extensions. It keeps track of them and cleans up after it's done, but in a test environment, we'd rather not have the possibility of tempfiles getting abandoned after a hang.
dunedain289
Those tempfiles are going to be stored in the system temporary folder. AFAIK even running as a service, temporary folders are safe and even dotNET creates them for running processes (and sometimes it doesn't clean after).Will that be such a huge problem? Can I know what is the need of such conservative scenario?
Luis Lavena
We've had a really conservative mindset because we're testing hardware, so we wan't to keep the environment as stable and deterministic as possible. I think we're going to give up on that and just use Ocra, since it seems the most solid so far.
dunedain289
OCRA is going to work good, as the temporary folder that is extracted is related to the process ID used assigned when the executable is called.This is similar to what Exerb does, except it does using Windows API for the filename assignation (and the only files extracted are extensions and DLLs)If you connect to that hardware using TCP sockets then OCRA may not be an option as it needs to open a firewall rule every time it gets executed. Exerb doesn't.Hope that Helps.
Luis Lavena
A: 

You can embed a Ruby interpreter and script into a C program, which may be easier than trying to run Crate. Here are some helpful links that describe how to do this, and may provide enough sample code to use as a skeleton for what you are trying to build.

bta
Unfortunately, this solution doesn't take the Ruby standard library into account. Without replicating something like crate/rubyscript2exe/etc, I'd still have to have all the .rb files somewhere.
dunedain289
I've only read about doing this (never tried it myself) but from what I can remember, you can embed the .rb files inside the C program and not have to carry them all around. A lot of the Ruby standard libraries are written in C and I believe they can all get compiled into your C application along with the interpreter.
bta