view · edit · sidebar · attach · print · history

Installing de.oddb on Snow-Leopard

<< DeoddbWindows | Index | Yus >>

Getting started

Install Postgresql Version 8.4 with the One-Click Installer from Dave Page

 http://www.enterprisedb.com/products/pgdownload.do#osx

You will need to install

 dbd-pg

but that will fail with

 checking for pg_config... no

So I found this post

 http://www.collectivenoodle.com/blog-articles/2009/10/7/trouble-with-the-postgres-ruby-gem-on-osx-106-pg-gem-on-snow.html

that says

 mdfind pg_config|grep bin|uniq

and that will return

 /Library/PostgreSQL/8.4/bin/pg_config

if you have the xcode developer-tools installed. So then you can do

 PATH=/Library/PostgreSQL/8.4/bin:$PATH gem install dbd-pg

that will take you to the next error

 checking for libpq-fe.h... no
 Can't find the 'libpq-fe.h header

according to this blog-post

 http://www.collectivenoodle.com/blog-articles/2009/10/7/trouble-with-the-postgres-ruby-gem-on-osx-106-pg-gem-on-snow.html

you still need to do

 sudo env ARCHFLAGS="-arch i386" gem install pg -- --with-pg-include=/Library/PostgreSQL/8.4/include/ --with-pg-lib=/Library/PostgreSQL/8.4/lib/

this freaking works!

 dbd-pg 0.3.9
 pg 0.10.0

both install, yes! Now install git for OS X

 http://code.google.com/p/git-osx-installer/downloads/detail?name=git-1.7.3.3-i386-leopard.dmg

Install the facets gem

 gem install -v=1.8.54 facets

So now I am still getting this error

 /Users/zdavatz/.gem/ruby/1.8/gems/dbi-0.4.1/lib/dbi.rb:294:in `load_driver': 
 Unable to load driver 'pg' (underlying error: wrong constant name pg) (DBI::InterfaceError)
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
	from /Users/zdavatz/.gem/ruby/1.8/gems/dbi-0.4.1/lib/dbi.rb:236:in `load_driver'
	from /Users/zdavatz/.gem/ruby/1.8/gems/dbi-0.4.1/lib/dbi.rb:154:in `_get_full_driver'
	from /Users/zdavatz/.gem/ruby/1.8/gems/dbi-0.4.1/lib/dbi.rb:139:in `connect'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:60:in `_connect'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:59:in `times'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:59:in `_connect'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:56:in `connect'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:56:in `synchronize'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:56:in `connect'
	from /Users/zdavatz/.gem/ruby/1.8/gems/odba-1.0.0/lib/odba/connection_pool.rb:19:in `initialize'
	from /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/lib/oddb/persistence/odba.rb:29:in `new'
	from /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/lib/oddb/persistence/odba.rb:29
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/lib/oddb/persistence.rb:4
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/bin/oddbd:10
	from /Users/zdavatz/.gem/ruby/1.8/bin/oddbd:19:in `load'
	from /Users/zdavatz/.gem/ruby/1.8/bin/oddbd:19

This should also pass according to http://rubyforge.org/forum/forum.php?set=custom&forum_id=958&style=nested&max_rows=50&submit=Change+View

 gem check --test dbi

but the output is

 Failure:
 test_available_drivers(TC_DBI) [/Users/zdavatz/.gem/ruby/1.8/gems/dbi-0.4.1/test/dbi/tc_dbi.rb:171]:
 <["dbi:Mysql:", "dbi:ODBC:", "dbi:Pg:", "dbi:SQLite3:", "dbi:SQLite:"]> expected but was
 <[]>.
 ERROR:  107 tests, 448 assertions, 1 failures, 0 errors

It seems that the pg driver is being loaded by odba

 ./oddb/persistence/odba.rb:  ODBA.storage.dbi = ODBA::ConnectionPool.new("DBI:pg:#{@config.db_name}",

So this changes some things

 vi oddb/persistence/odba.rb

and add the two lines

 require 'rubygems'
 require 'pg'

takes you to this error

 /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/lib/oddb.rb:4: warning: already initialized constant VERSION
 /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle, 9): no suitable image found.  Did find: (LoadError)
	/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/pg-0.10. /lib/pg_ext.bundle
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg.rb:12

so now I am downgrading to pg 0.8.0 as Masa recommends here http://dev.ywesee.com/wiki.php/Masa/20101223-testcase-chOddbOrg-genericsXls#install_pg

 /Library/Ruby/Gems/1.8/gems/pg-0.8.0/lib/pg.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.8.0/lib/pg.bundle, 9): no suitable image found.  Did find: (LoadError)
	/Library/Ruby/Gems/1.8/gems/pg-0.8.0/lib/pg.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/pg-0.8.0/lib/pg.bundle
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
	from /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/lib/oddb/persistence/odba.rb:9
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Users/zdavatz/.gem/ruby/1.8/gems/de.oddb-2.0.0/lib/oddb/persistence.rb:4

same error

 sudo env ARCHFLAGS="-arch i386 -arch x86_64" gem install -v=0.8.0 pg -- --with-pg-include=/Library/PostgreSQL/8.4/include/ --with-pg-lib=/Library/PostgreSQL/8.4/lib/

does not compile an results in

 compat.c:539: error: old-style parameter declarations in prototyped function definition
 compat.c:539: error: expected ‘{’ at end of input
 lipo: can't open input file: /var/tmp//ccpybThJ.out (No such file or directory)
 make: *** [compat.o] Error 1

and again just with

 sudo env ARCHFLAGS="-arch x86_64" gem install -v=0.8.0 pg

results in

 compat.c:339: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 compat.c:386: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 compat.c:465: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 compat.c:539: error: old-style parameter declarations in prototyped function definition
 compat.c:539: error: expected ‘{’ at end of input
 make: *** [compat.o] Error 1

according to

 uname -a 

on a MacBook Air

 Darwin zrr-MacBook-Air.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386

we are on

 i386

not 64-bit, even if the processor does support 64bit according to MacTracker. Tip courtesy to Dataquest.
This is also a nice way to see if

 pg

loads correctly

 irb

then type

 require 'pg'

that results in

 LoadError: dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle, 9): no suitable image found.  Did find:
	/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle
	from /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg.rb:12
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
	from (irb):1

This also offers some more interesting information of my Mac

 ruby -rrbconfig -e 'p Config::CONFIG["CFLAGS"]'

results in

 "-arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  "

Also

 pg_config --cflags

results in

 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -headerpad_max_install_names -arch ppc -arch i386 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv

tips are from Michael Granger https://bitbucket.org/ged/ruby-pg/issue/32/installation-problems-on-mac-os-x-snow

view · edit · sidebar · attach · print · history
Page last modified on January 15, 2011, at 04:27 PM