Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Mike Pomraning
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2010-05-25 04:10
> ... Could not load driver (uninitialized constant MysqlError) (DBI::InterfaceError)

Today I had and overcame this exact problem. Suggestion: remove your "mysql/ruby" gem or package install, and rebuild and reinstall. (Or switch to the pure ruby ruby/mysql.)

Background: My "mysql/ruby" (C extension) gem was built against libmysqlclient.so.15, but I had since upgraded to a server version with ...so.16.

The gem installation appeared to swallow the error (loading "mysql_api" failed silently, I think). Frustrating.

In any case, rebuilding and reinstalling did the trick.

By: ~ ~
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-09-07 10:31
Ok. I eventually got it to work. However, I had to install Ruby 1.8.7 instead.

This is a step by step 'guide' for Ubuntu 9.04 in case someone finds it useful.
http://pastie.org/private/x3p9z5vz0djjwgami9rpgw

I guess the reason why 1.9.1 didn't work (Eventhough I've done exactly the same steps) is that some of the prequisites dont come along with it too well :/

Either way I am happy I can start working with it finally =) Shame it took some time, though :P


By: Mike Pomraning
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-09-06 14:50
> ruby -rmysql -e 'p Mysql::VERSION'
> -e:1:in `<main>': uninitialized constant
> Mysql::VERSION (NameError)

``require "mysql"'' is not giving a fatal error, but it is not finding the mysql-ruby package that we expect. ``DBI.connect("dbi:Mysql...")'' gives you a different error, but I'd similarly suspect that it is silently failing to find dbd/Mysql.rb.

I think if you can solve why the ``p Mysql::VERSION'' test didn't work, you'll have
found the problem for ``DBI.connect()'' as well.

However, this seems squarely an installation problem now. The answer is somewhere in

$ ruby -rmysql -e 'puts $"'
-or-
$ strace -s 1024 -e trace=file -rmysql -e 0

but may take a while to find.

-Mike

By: ~ ~
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-09-06 10:23
Hi,

GEMS:
dbd-mysql (0.4.3)
dbi (0.4.2)
deprecated (2.0.1)
mysql (2.8.1)

which ruby #=> /usr/local/bin/ruby
ruby --version #=> ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]


ruby -rmysql -e 'p Mysql::VERSION'
returns:
-e:1:in `<main>': uninitialized constant Mysql::VERSION (NameError)


ruby -rdbi -e 'DBI.connect("dbi:Mysql:test", "me", "foo")
returns: the DBI::InterfaceError I pasted before


strace -e trace=open ...COMMAND... 2>&1 | grep -iE 'mysql.*(rb|so)' | grep -v ENOENT
returns: nothing

By: Mike Pomraning
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-09-06 05:19
Michal,

What is the smallest code that reproduces your symptoms? Something like:

$ ruby-1.9.1-p243 -rdbi -e 'DBI.connect("dbi:Mysql:test", "me", "foo")'
... (DBI::InterfaceError) ...

What version of mysql-ruby are you running? Something like:
$ ruby-1.9.1-p243 -rmysql -e 'p Mysql::VERSION'

Are each of those commands finding the *same* mysql-ruby installation? Compare something like:

$ strace -e trace=open ...COMMAND... 2>&1 | grep -iE 'mysql.*(rb|so)' | grep -v ENOENT

Regards,
Mike

By: Mike Pomraning
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-09-06 05:08
Helio,

Your installation is suspect. My suggestion is to wipe your ruby install and start over, *without* installing any dbi or dbd modules under site_ruby.

Rationale:

You have a "site_ruby" dbi (installed under lib/ruby/site_ruby/1.8) which is blocking ruby's view of the "gem" dbi (v0.4.2, installed under lib/ruby/gems/1.8/gems).

You have also manually copied a single file from a multi-file gem library to the site_ruby tree. Don't do that, please! :)

The "site_ruby" dbi is perhaps ancient -- we don't know its version from the information you've posted, but we do know it doesn't understand DBI::TypeUtil. (Is it the dbi-0.2.2 that ships with the ruby-1.8.6-p??? installer for Windows, out of curiosity?) This isn't the dbi you want.

Regards,
Mike

By: ~ ~
RE: DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-09-05 20:06
I've got a similar problem.

This is what I've done on a clean Ubuntu 9.0.4 installation.

1. Installed ruby 1.9.1p243 from source
2. sudo apt-get install mysql-server
3. sudo apt-get install libmysqlclient15-dev (Turned out to be an important package, otherwise the mysql gem wont install)
4. sudo gem install mysql -- --with-mysql-dir=/usr/include/mysql
5. sudo gem install dbi

I've tested the same example codes and I am getting this:


/usr/local/lib/ruby/gems/1.9.1/gems/dbi-0.4.2/lib/dbi.rb:318:in `rescue in load_driver': Could not load driver (uninitialized constant MysqlError) (DBI::InterfaceError)
from /usr/local/lib/ruby/gems/1.9.1/gems/dbi-0.4.2/lib/dbi.rb:242:in `load_driver'
from /usr/local/lib/ruby/gems/1.9.1/gems/dbi-0.4.2/lib/dbi.rb:160:in `_get_full_driver'
from /usr/local/lib/ruby/gems/1.9.1/gems/dbi-0.4.2/lib/dbi.rb:145:in `connect'
from mysql.rb:8:in `<main>'

Any help would be appreciated.
It's a great gem, but not being able to use it just makes me want to cry :(

By: Helio Rodrigues
DBI.connect error-uninitialized Mysql:Driver [ reply ]  
2009-07-30 14:08
Hey all...

The code I'm testing is:

require "dbi" (or "DBI")

class test_dbi

def selectAll

begin
# connect to the MySQL server
dbh = DBI.connect("DBI:Mysql:CMASDB_V41_2:192.168.253.29", "cmasAdmin", "cmas_admin")
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
dbh.disconnect if dbh
end

end

end


With this code I got the follwing error message:

Could not load driver (uninitialized constant Mysql::Driver)
RAILS_ROOT: C:/eclipse322/workspace/cmas41_rails

Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:511:in `load_driver'
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
app/models/test_dbi.rb:11:in `selectAll'


Then I tried:

require "rubygems"
require "dbi"
gem "dbd-mysql"


And I got:

Could not load driver (no such file to load -- DBD/mysql/mysql)

RAILS_ROOT: C:/eclipse322/workspace/cmas41_rails

Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:511:in `load_driver'
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
app/models/test_dbi.rb:13:in `selectAll'


So I figured out that there is no mysql directory in C:\ruby\lib\ruby\site_ruby\1.8\DBD
And I copied the file C:\ruby\lib\ruby\gems\1.8\gems\dbd-mysql-0.4.3\lib\dbd\Mysql.rb to the folder C:\ruby\lib\ruby\site_ruby\1.8\DBD\MYSQL.

And tried again and have a different error:

Could not load driver (uninitialized constant DBI::TypeUtil)
RAILS_ROOT: C:/eclipse322/workspace/cmas41_rails

Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:511:in `load_driver'
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_driver'
C:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
app/models/fedag_dbi.rb:13:in `selectAll'



I installed using gem install the follwing packages:

C:\>gem install dbi
Successfully installed dbi-0.4.2
1 gem installed
Installing ri documentation for dbi-0.4.2...
Installing RDoc documentation for dbi-0.4.2...

C:\>gem instal dbd-mysql
Successfully installed dbd-mysql-0.4.3
1 gem installed
Installing ri documentation for dbd-mysql-0.4.3...
Installing RDoc documentation for dbd-mysql-0.4.3...

C:\>gem install dbd-pg
Successfully installed dbd-pg-0.3.8
1 gem installed
Installing ri documentation for dbd-pg-0.3.8...
Installing RDoc documentation for dbd-pg-0.3.8...

C:\>
C:\>
C:\>
C:\>gem install ruby-oci8
Successfully installed ruby-oci8-2.0.2-x86-mswin32-60
1 gem installed
Installing ri documentation for ruby-oci8-2.0.2-x86-mswin32-60...
Installing RDoc documentation for ruby-oci8-2.0.2-x86-mswin32-60...


My gem list is:

C:\>gem list

*** LOCAL GEMS ***

actionmailer (2.1.2)
actionpack (2.1.2)
activerecord (2.1.2)
activeresource (2.1.2)
activesupport (2.1.2)
builder (2.1.2)
cgi_multipart_eof_fix (2.5.0)
ci_reporter (1.6.0)
columnize (0.3.0)
commonwatir (1.6.2)
dbd-mysql (0.4.3)
dbd-pg (0.3.8)
dbi (0.4.2)
deprecated (2.0.1)
firewatir (1.6.2)
fxri (0.3.6)
fxruby (1.6.6)
gem_plugin (0.2.3)
highline (1.5.1)
hoe (1.12.2)
hpricot (0.4)
linecache (0.43)
log4r (1.0.5)
mongrel (1.1.5)
mongrel_cluster (1.0.5)
mysql (2.7.3)
net-sftp (2.0.2)
net-ssh (2.0.11)
paginator (1.1.1)
pg (0.8.0)
rails (2.1.2)
rake (0.8.7, 0.7.2)
rcov (0.8.1.2.0)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
ruby-oci8 (2.0.2)
ruby-postgres (0.7.1.2006.04.06)
rubyforge (1.0.3)
rubygems-update (1.3.3)
s4t-utils (1.0.4)
sources (0.0.1)
tzinfo (0.3.13)
user-choices (1.1.6)
watir (1.6.2)
win32-api (1.4.0)
win32-clipboard (0.4.1)
win32-dir (0.3.1)
win32-eventlog (0.4.3)
win32-file (0.5.3)
win32-file-stat (1.2.3)
win32-process (0.6.0, 0.5.1)
win32-sapi (0.1.3)
win32-sound (0.4.0)
windows-api (0.3.0)
windows-pr (1.0.5, 0.6.2)
xml-simple (1.0.12)


I'm working on this for the last 2 days and I have no idea of how to solve this.

Any help will be apreciated!

--Helio