Saturday, August 28, 2010

Installing sequel - a Ruby gem for database access

1. Install sequel
$ sudo gem1.9.1 install sequel 
Successfully installed sequel-3.14.0
1 gem installed
Installing ri documentation for sequel-3.14.0...
Updating class cache with 1382 classes...
Installing RDoc documentation for sequel-3.14.0...
$ sudo gem install sequel  # gem1.8
Successfully installed sequel-3.14.0
1 gem installed
Installing ri documentation for sequel-3.14.0...
Installing RDoc documentation for sequel-3.14.0...

2. Install PostgreSQL lib for Ruby
a. Synaptic
b. Search and install
- libpg-ruby
- libpg-ruby1.8
- libpg-ruby1.9.1
- libpg-ruby-doc

3. Install PostgreSQL dev version.
I am failing to install postgres/pg gem.
$ sudo gem install postgres
Building native extensions.  This could take a while...
ERROR:  Error installing postgres:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:46: command not found: pg_config --includedir
extconf.rb:53: command not found: pg_config --libdir
checking for main() in -lpq... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
...
$ sudo gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for pg_config... no
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
...

But I do not want to build PG from sources. So I install a dev version.
a. Synapitic
b. Find and Install postgresql-server-dev-8.4.

4. Now ready to install posgres/pg gem.
Actually I am confused of these two gems: postgres and pg.
I found posrgres gem fails to install for gem1.9.1, but pg installs on both versions, 1.8 and 1.9.1.

$ sudo gem install postgres
Building native extensions.  This could take a while...
Successfully installed postgres-0.7.9.2008.01.28
1 gem installed
Installing ri documentation for postgres-0.7.9.2008.01.28...
Installing RDoc documentation for postgres-0.7.9.2008.01.28...
$ sudo gem1.9.1 install postgres
Building native extensions.  This could take a while...
 ERROR:  Error installing postgres:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:4:in : uninitialized constant PLATFORM (NameError)
$ sudo gem1.9.1 install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0...
Updating class cache with 1720 classes...
Installing RDoc documentation for pg-0.9.0...
$ sudo gem install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0...
Installing RDoc documentation for pg-0.9.0...

No comments:

Post a Comment