Hello,
I’m writing some prototype using mod_ruby, REXML and ruby-dbi;
code was done at home system (running “stable” thus somewhat
outdated software, notably ruby-1.6.6) and made working, then
brought to “current” system at my work. Here the troubles began.
In the end it seems to me that with:
- ruby 1.7.3 (Alexander Bokovoy’s build);
- ruby-postgres 0.7.1 (distro build),
- ruby-dbi 0.0.18 (my build)
- mod_ruby-1.0.2 (distro build)
mod_ruby would break this example which would run fine directly:
— test.rbx —
#!/usr/bin/ruby
require 'dbi’
DBI.connect(‘DBI:Pg:test’, ‘mike’, ‘’) do | dbh |
dbh.do(“insert into test (t) values (?)”, Time.now.to_i)
end
puts
···
with the following error message:
[Wed Jan 15 19:28:44 2003] [error] mod_ruby: error in ruby
/var/www/html/logotron/test.rbx:3: undefined method connect' for DBI:Module (NoMethodError) from /usr/share/ruby/vendor_ruby/1.7/apache/ruby-run.rb:70:in
load’
from /usr/share/ruby/vendor_ruby/1.7/apache/ruby-run.rb:70:in `handler’
The trouble seems to be this line in apache/ruby-run.rb:
load(filename, true)
Changing wrap parameter to false would yield no errors but
doesn’t seem like a solution. Alexander proposed the following:
mod = Module.new
class << mod
File.open(module_file) {|f| instance_eval(f.readlines.join("\n"))}
end;
as a substitution for require but could the problem be solved
in more generic manner? In the end, it worked on 1.6
PS: odd thing: after having reverted the changes to ruby-run.rb
and restarting apache again, it seems to grok the test.
(in half an hour)
So for now it just works. For now doesn’t.
(in two hours)
Regarding the prototype, there’s even more fun. Five POSTs in
row, three get Internal Server Error (undefined method `connect’
for DBI:Module), two pass and insert…
Blows up with:
[Wed Jan 15 22:09:33 2003] [error] mod_ruby: error in ruby /usr/share/ruby/1.7/date/format.rb:4: Date is not a class (TypeError)
from /usr/share/ruby/1.7/parsedate.rb:4:in require' from /usr/share/ruby/1.7/parsedate.rb:4 from /usr/share/ruby/vendor_ruby/1.7/dbi/sql.rb:8:in
require’
from /usr/share/ruby/vendor_ruby/1.7/dbi/sql.rb:8
from /usr/share/ruby/vendor_ruby/1.7/dbi/dbi.rb:35:in require' from /usr/share/ruby/vendor_ruby/1.7/dbi/dbi.rb:35 from /usr/share/ruby/vendor_ruby/1.7/dbi.rb:1:in
require’
from /usr/share/ruby/vendor_ruby/1.7/dbi.rb:1
from /var/www/html/logotron/index.rbx:43:in require' from /var/www/html/logotron/index.rbx:43 from /usr/share/ruby/vendor_ruby/1.7/apache/ruby-run.rb:71:in
load’
from /usr/share/ruby/vendor_ruby/1.7/apache/ruby-run.rb:71:in `handler’
Strange, eh?
–
---- WBR, Michael Shigorin mike@altlinux.ru
------ Linux.Kiev http://www.linux.kiev.ua/