From: Graham Smith Date: 2009-01-10T19:24:05+09:00 Subject: Re: Using DBI and MySQL gems Owein Herrmann wrote: > Erik Hollensbe wrote: > >> require "rubygems" >> require "dbi" > What about the mysql package? Don't you have to do something to load > that? > >> dbh = DBI.connect("DBI:Mysql:rubytest:localhost", "root") > Using the lines above, this is where is breaks. It cannot locate the > mysql driver. If I add "require 'mysql'", then I get: > DBI::InterfaceError: Could not load driver (uninitialized constant > Mysql::Driver) > from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:344:in `load_driver' > from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:227:in > `_get_full_driver' > from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect' > > The only correct way I have to initialize these packages for use seems > to be using the "gem" command, and then I have to require "dbi". Oh > well. At least it works. >> If this breaks on your system, I'd be looking elsewhere (of ruby, >> rubygems, and dbi... likely in the direction of your package >> maintainers) to solve your problem. > > I'm not sure what you mean by package maintainers... Did this ever get solved? I have just built a new setup and wanted to try ruby rails on it. It's Centos 5.2 gem env RubyGems Environment: - RUBYGEMS VERSION: 1.3.1 - RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i686-linux] - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/local/bin/ruby - EXECUTABLE DIRECTORY: /usr/local/bin - RUBYGEMS PLATFORMS: - ruby - x86-linux - GEM PATHS: - /usr/local/lib/ruby/gems/1.8 - /home/grehom/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://gems.rubyforge.org/ mysql is working fine [grehom@localhost mysql]$ mysql --version mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (i686) using readline 5.0 I get the same error running Erik's script: [grehom@localhost mysql]$ ruby erics_test.rb /usr/local/lib/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi.rb:294:in `load_driver': Unable to load driver 'Mysql' (underlying error: uninitialized constant DBI::DBD::Mysql) (DBI::InterfaceError) from /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' from /usr/local/lib/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi.rb:236:in `load_driver' from /usr/local/lib/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi.rb:154:in `_get_full_driver' from /usr/local/lib/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi.rb:139:in `connect' from erics_test.rb:6 [grehom@localhost mysql]$ -- Posted via http://www.ruby-forum.com/.