Page 1 of 1

FS & Custom Ruby Installation

Posted: Mon May 13, 2013 10:27 pm
by Drnkhobo
. . .Oh Ruby, show me your delights. Do not obscure from me, for I am one with you. . .

Ahhh ok I want to start a thread here which goes into the topic of using custom Ruby source in FS apps.
Based on this thread: http://www.dsprobotics.com/support/viewtopic.php?f=2&t=941

So for my first endeavor I want to make a FS exe that connects to the net using Ruby's standard net/http libraries. Which will then, from inside the app, connect to a webpage & parse the html.

The second journey for us would be to use the EZCrypt gem & encrypt a string inside Ruby.



Let's start at no.1 shall we?

My understanding is that to get the net/http libraries included in Ruby, you need to compile your own Ruby source.

So I followed digitalwhitebyte's advice:


Get the source zip from the download page,

After downloaded unzip it locally to say c:\ruby-src
Open CMD prompt, but make sure you run it as administrator,
run vcvars32.bat, you can locate it in your MSV folder like <MSV path>\VC\bin
Make a folder for your build say c:\ruby-build. Move into it / change dir

c:\ruby-build> c:\ruby-1.9.3-p0\win32\configure.bat
c:\ruby-build> nmake
c:\ruby-build> nmake test
c:\ruby-build> nmake DESTDIR=c:/ruby-build install

To use them, then you can simply link them like
$LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1"
$LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1/i386-mswin32_90"

All compiled 'n snug in a bug in a rug with a . . .you get the point :roll:

So I load up FS, make a Ruby module and type:

$LOAD_PATH << "C:/ruby-build/usr/lib/ruby/1.9.1/i386-mswin32_90"
reuire 'net/http'


Grrrr. . .Ruby isnt playing nice here! Its saying the socket.so file isnt compatible. So I find the socket.so file in my compiled Ruby & place it in the FS lib folder.

Aw damn! Now Ruby is telling me: uninitialized constant Encoding::UTF_7
Google search returns some info but mostly side shoots rather than trunks :(

but ahah! something glistening in the wet dark google search . . . .

Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with various class names in place of Something).

Solution: You've most likely referred to a class or module that doesn't exist. Most likely, you've forgotten to require a gem or library needed for the code to work, or you've made a typo. Another possibility is that the class you'd like to refer to is in another module. If that's the case, you'll have to refer to it with its full name as in the following code.


#!/usr/bin/env ruby

module MyModule
class MyClass; end
end

c = MyModule::MyClass.new


hmm so it seems that Encoding::UTF_7 is used in openssl. Ive checked my libs for that but its not in the compiled folder of Ruby.

Has anyone used this before?

Are there easier ways. . . gems???? :lol:

Re: FS & Custom Ruby Installation

Posted: Tue May 14, 2013 6:28 pm
by digitalwhitebyte
what error you have when compiled the source?

Re: FS & Custom Ruby Installation

Posted: Tue May 14, 2013 8:00 pm
by Drnkhobo
omg thank you Dwb!

Well i noticed that when I compiled
c:\ruby-build> nmake


When it came to installing openssl, it just said failed! I cant remember if it gave a reason. . .

Am I doing this correctly? To say that the "$LOAD_PATH. . . " line tells Ruby to look into that folder for files too?

Re: FS & Custom Ruby Installation

Posted: Tue May 14, 2013 11:02 pm
by digitalwhitebyte
sorry but I did not understand, you were able to compile the source?

Re: FS & Custom Ruby Installation

Posted: Wed May 15, 2013 6:51 pm
by Drnkhobo
Yeah it compiled fine, just not with the openssl libs.
Capture.PNG
Capture.PNG (6.43 KiB) Viewed 20629 times

Re: FS & Custom Ruby Installation

Posted: Wed May 15, 2013 11:03 pm
by digitalwhitebyte
Ok, now to install rubygems there are still two libraries to compile, yaml and zlib from source,
a bit complex to do.
I try to tidy up the procedure and ready as soon as I add it to the original post.

however this is done,
every time you install a rubygem will always have to launch the file vcvars32.bat first before giving in the console, the command to install the gems.
and verify that the environment variables in the PATH variable there is the path of the ruby that you compiled.
this need because some gems is compiled from C code,
and ruby need to know the paths of the compiler in use on the system.

but keep in mind that they did all this, some gems will not be able to function,
because the code will turn off if a thread takes too long to finish its execution.
especially with executions of code to use web connections, they use a socket that is executed in a loop running,
it definitely will block the ruby code.

Re: FS & Custom Ruby Installation

Posted: Thu May 16, 2013 8:35 pm
by Drnkhobo
especially with executions of code to use web connections, they use a socket that is executed in a loop running,
it definitely will block the ruby code.

So basically network & Ruby is out the window?

Re: FS & Custom Ruby Installation

Posted: Thu May 16, 2013 11:10 pm
by digitalwhitebyte
can not use anything that has a thread that does not end in a period of time imposed by Malc to judge that a ruby execution is blocked.
all this because at the end of ruby does not run in a multithreaded environment.

Re: FS & Custom Ruby Installation

Posted: Fri May 17, 2013 12:35 am
by digitalwhitebyte
Guide updated
How I built libyaml