Rubyscript2exe error

G

Graham

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

Erik Veenstra

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.erikveen.dds.nl/
 
G

Graham

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

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top