Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Nov 2009 17:24:30 +0100
From:      Penty Wenngren <penty.wenngren@dgc.se>
To:        Stanislav Sedov <stas@FreeBSD.org>
Cc:        "ruby@FreeBSD.org" <ruby@FreeBSD.org>
Subject:   Re: Ruby, dbi and PostgreSQL
Message-ID:  <20091112162430.GP74360@picard.dgc.se>
In-Reply-To: <20091111100826.e0dcfdca.stas@FreeBSD.org>
References:  <20091111160649.GL74360@picard.dgc.se> <20091111100826.e0dcfdca.stas@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Nov 11, 2009 at 07:08:26PM +0100, Stanislav Sedov wrote:
> On Wed, 11 Nov 2009 17:06:49 +0100
> Penty Wenngren <penty.wenngren@dgc.se> mentioned:
> 
> > Hello,
> > 
> > After having upgraded our installed ports this morning we have a few
> > machines that no longer want to play with ruby, dbi and postgres. This
> > is the output I get when trying to do this in irb:
> > 
> > irb(main):001:0> require 'dbi'
> > => true
> > irb(main):002:0> dbh = DBI.connect("DBI:Pg:test","test","test")
> > DBI::InterfaceError: Could not load driver (Could not find driver Pg or pg (error:
> > no such file to load -- pg))
> >     from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:318:in `load_driver'
> >     from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:160:in `_get_full_driver'
> >     from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:145:in `connect'
> >     from (irb):2
> > 
> > 
> > irb(main):001:0> require 'dbd/Pg'
> > LoadError: no such file to load -- pg
> >         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> > `gem_original_require'
> >         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> > `require'
> >         from /usr/local/lib/ruby/site_ruby/1.8/dbd/Pg.rb:40
> >         from (irb):1:in `require'
> >         from (irb):1
> > 
> > 
> > # ls -l /usr/local/lib/ruby/site_ruby/1.8/dbd/
> > total 10
> > -rw-r--r--  1 root  wheel  6579 Nov 11 16:17 Pg.rb
> > drwxr-xr-x  2 root  wheel   512 Nov 11 16:17 pg
> > 
> > 
> > # pkg_info | grep ruby
> > mod_ruby-1.3.0      An Apache module that embeds Ruby interpreter within
> > ruby+nopthreads-1.8.7.160_5,1 An object-oriented interpreted scripting language
> > ruby18-aspectr-0.3.5 Ruby libraries for Aspect programming
> > ruby18-bdb-0.6.5_1  Ruby interface to Sleepycat's Berkeley DB revision 2 or lat
> > ruby18-dbd_pg-0.3.8 PostgreSQL driver for DBI-for-Ruby
> > ruby18-dbi-0.4.3    DBI-for-Ruby - a common interface for SQL-based databases
> > ruby18-eruby-1.0.5_1 Interprets Ruby code embedded in a text file like PHP/ePerl
> > ruby18-fcgi-0.8.7   FastCGI library for Ruby
> > ruby18-gems-1.3.5   Package management framework for the Ruby language
> > ruby18-mmap-0.2.6   Ruby interface to manage memory-mapped file objects
> > ruby18-postgres-0.7.9.2008.01.28_1 Ruby interface to PostgreSQL library
> > ruby18-setup.rb-3.4.1 Common installer script for ruby packages
> > rubygem-deprecated-2.0.1 A library intended to aid developers working with
> > deprecate
> > rubygem-postgres-0.7.9.2008.01.28_1 Ruby interface to PostgreSQL library
> > 
> > 
> > I have tried to reinstall ruby and all of its dependencies, but no luck.
> > 
> > I hope you can shed some light on what went wrong. The packages that were
> > upgraded this morning (iirc) are:
> > 
> > ruby+nopthreads-1.8.7.160_5,1
> > ruby18-aspectr-0.3.5
> > ruby18-dbd_pg-0.3.8
> > ruby18-dbi-0.4.3
> > ruby18-gems-1.3.5
> > ruby18-postgres-0.7.9.2008.01.28_1
> > rubygem-deprecated-2.0.1
> > rubygem-postgres-0.7.9.2008.01.28_1
> > 
> > 
> > // Penty
> > 
> > -- 
> > 
> 
> Hi, Penty!
> 
> I'm not sure this is the case, but I'd guess that postgresql client
> library is threaded and ruby is not, so it can't load the postgresql
> library.  What FreeBSD version do you use?  Pthreaded ruby on everything
> before 7.2 is not fully functional (e.g. fork won't work as it requires
> malloc implementation to support forking in threaded program).
> 
> The best way for you if you're using postgresql in ruby will be to
> update the OS to 7.2 or above.  You can also try to use ruby with
> threades (by commenting the '# pthreads in earlier versions has problems with malloc after fork' section in Makefile), but keep in mind that
> fork and other fork(2)-based functions won't work.
> 
> -- 
> Stanislav Sedov
> ST4096-RIPE


Hello again!

I have now tried the same on a 7.2 system, and I get the same error:

# uname -mprsv
FreeBSD 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Fri Oct  2 08:22:32 UTC 2009
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64 amd64

# pkg_info 
autoconf-2.62       Automatically configure source code on many Un*x platforms 
autoconf-wrapper-20071109 Wrapper script for GNU autoconf
automake-1.10.1     GNU Standards-compliant Makefile generator (1.10)
automake-wrapper-20071109 Wrapper script for GNU automake
gettext-0.17_1      GNU gettext package
gmake-3.81_3        GNU version of 'make' utility
help2man-1.36.4_3   Automatically generating simple manual pages from program o
libdbi-0.8.3        Database Independent Abstraction Layer for C
libdbi-drivers-0.8.3.1_2 Drivers for libdbi
libiconv-1.13.1     A character set conversion library
libtool-2.2.6a_1    Generic shared library support script
m4-1.4.13,1         GNU m4
p5-gettext-1.05_2   Message handling functions
perl-5.8.9_3        Practical Extraction and Report Language
portaudit-0.5.14    Checks installed ports against a list of security vulnerabi
postgresql-client-8.3.7,1 PostgreSQL database (client)
ruby-1.8.7.160_5,1  An object-oriented interpreted scripting language
ruby18-aspectr-0.3.5 Ruby libraries for Aspect programming
ruby18-dbd_pg-0.3.8 PostgreSQL driver for DBI-for-Ruby
ruby18-dbi-0.4.3    DBI-for-Ruby - a common interface for SQL-based databases
ruby18-gems-1.3.5   Package management framework for the Ruby language
ruby18-postgres-0.7.9.2008.01.28_1 Ruby interface to PostgreSQL library
rubygem-deprecated-2.0.1 A library intended to aid developers working with
deprecate

# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'dbi'
=> true
irb(main):003:0> dbh = DBI.connect("DBI:Pg:test","test","test")
DBI::InterfaceError: Could not load driver (Could not find driver Pg or pg (error:
no such file to load -- pg))
        from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:318:in `load_driver'
        from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:160:in `_get_full_driver'
        from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:145:in `connect'
        from (irb):3


// Penty

-- 

Penty Wenngren
DGC Solutions AB



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091112162430.GP74360>