Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 333055

Summary: USE=postgres =dev-ruby/ruby-dbi-0.2.0-r1 lacks dev-ruby/pg depend
Product: Gentoo Linux Reporter: Sergei Trofimovich (RETIRED) <slyfox>
Component: New packagesAssignee: Gentoo Ruby Team <ruby>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 333087    
Bug Blocks:    

Description Sergei Trofimovich (RETIRED) gentoo-dev 2010-08-16 18:54:33 UTC
amd64 mostly stable gentoo:

Trying to use sample test below leads to module loading failure:
$ ruby a.rb 
/usr/lib64/ruby/site_ruby/1.8/dbi.rb:368:in `load_driver': Could not load driver (no such file to load -- pg) (DBI::InterfaceError)
        from /usr/lib64/ruby/site_ruby/1.8/dbi.rb:233:in `_get_full_driver'
        from /usr/lib64/ruby/site_ruby/1.8/dbi.rb:219:in `connect'
        from a.rb:19:in `with_db'
        from a.rb:35


Emerging ~arch 'dev-ruby/pg' helps the situation.

Sample test a.rb:

#!/usr/bin/ruby

require 'dbi'

module DB_CONF
    DRIVER = 'Pg'
    HOST   = 'foo_host'
    DB     = 'foo_DB'
    USER   = 'foo_USER'
    PASS   = 'foo_pas'
end

def with_db(*block)
    if ! block_given?
        raise "no block given"
    end

    result = nil
    DBI.connect("dbi:#{DB_CONF::DRIVER}:#{DB_CONF::DB}:#{DB_CONF::HOST}",
                DB_CONF::USER, DB_CONF::PASS) {|dbh|
        #$log.info("connected to db")
        dbh['AutoCommit'] = false
        begin
            result = yield dbh
            dbh.commit
        rescue => e
            dbh.rollback
            #log_exception("with_db", e)
            raise e
        end
    }
    result
end

with_db{|dbh|
    query = dbh.prepare("SELECT * FROM foo")
    query.execute
    row = query.fetch()
}
Comment 1 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-08-16 23:13:10 UTC
Okay we need a newer version that uses ruby-ng, since this one is still old style...
Comment 2 Hans de Graaff gentoo-dev Security 2010-09-18 12:52:48 UTC
I'm closing this as WONTFIX since ruby-dbi-0.4.3 does depend on dev-ruby/pg and is stable on most arches now.