[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rubyscript2exe error

Graham

6/7/2005 2:27:00 PM

C:\>rubyscript2exe effluent.rb
Tracing effluent ...
Gathering files...
Copying files...
Creating effluent.exe ...

C:\>effluent
Error message: is not a class/module

the being executed is:-
require 'dbi'
# check if this exists - and if so then the ruby2exe script is
satisfied and we can exit
# must be placed after the require statements
exit if defined?(REQUIRE2LIB)

# Open the connection to the database and get the handle
def doConnection
begin
dbh = DBI.connect('DBI:Oracle:tpdev', 'username', 'pwd');
rescue
puts "Error message: #{$!}"
end
return dbh # could be nil if failed to connect
end

dbh = doConnection

The twist is.. that if I run
c:\ruby effluent.rb
.... then the program runs and connects to the database
Why?

3 Answers

Erik Veenstra

6/7/2005 8:40:00 PM

0

> The twist is.. that if I run
>
> c:\ruby effluent.rb
>
> ... then the program runs and connects to the database Why?

Well, I do the same on Linux, without RubyScript2Exe:

$ ruby troep.rb
Error message: is not a class/module

The problem (on my machine) is not caused by RubyScript2Exe.
The question is: What is the real cause? Removing the rescue
stuff might give us a hint:

$ ruby troep.rb
/usr/lib/ruby/1.8/dbi/dbi.rb:499:in `load_driver': is not a
class/module (TypeError)
from /usr/lib/ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
from /usr/lib/ruby/1.8/dbi/dbi.rb:381:in `connect'
from troep.rb:9:in `doConnection'
from troep.rb:16

A couple of "puts 'DEBUG'" in "dbi/dbi.rb" later, I found this:

$:.each do |dir|
path = "#{dir}/#{DBD::DIR}"
...
end

This is where my situation and RubyScript2Exe come together. My
machine is missing the DBD (libdbd?) stuff. The full Ruby
installation on your machine is OK, but RubyScript2Exe doesn't
embed these directories/files, so the embedded Ruby
installation isn't complete. Even when running the generated
executable on your own machine, it simply won't work.

This means that I have to include some extra code to detect the
usage of DBI. Since I don't know anything of DBI, I need your
(plural) help...

Any ideas?

gegroet,
Erik V. - http://www.erikve...

Graham Foster

6/7/2005 10:14:00 PM

0

> This means that I have to include some extra code to detect the
> usage of DBI. Since I don't know anything of DBI, I need your
> (plural) help...
>
> Any ideas?
As I newbie - highly doubful.. but what if we removed the line
exit if defined?(REQUIRE2LIB)
That would make the program run, and (presumably) load all the
necessary bits into memory. Would RubyScript2Exe then work OK once
there was a complete running memory image available? (or have I got
the wrong idea as to how Rubyscrpt2exe works?)
Graham

Graham

6/8/2005 8:32:00 AM

0

... having just tried it, I can say YES it works. I moved the exit if
defined statement beyond the code which connected to the database and
prepared the statement handle...and then Rubyscript2exe produced an
..exe which worked standalone on a different Windows machine (without
Ruby installed).
Neat.
Graham