Installing native Postgres gem for ruby

Recently did wonder about how to replace the slow postgres-pr library
with the native postgres version. Unfortuately the native client is not
that easy to install, especially without having cygwin installed.

You’ll need the postgres installation files for windows, best is the
zipped version without the installier, for example, as you only need to copy
a few files out of it.

Then you need to use gem to install the postgres extension:

c:\>gem install ruby-postgres
2. ruby-postgres (mswin32)
> 2

(choose the latest mswin32 build)

Usually everything should be done now, but wait, testing it with:

c:\> irb
irb(main):001:0> require 'postgres'

gives an error ! You need to go back to the postgres installer file and
copy a couple of libraries to the ruby “bin” file (for example in

  • comerr32.dll
  • krb5_32.dll
  • libeay32.dll
  • libiconv-2.dll
  • libintl-2.dll
  • libpq.dll
  • ssleay32.dll

Don’t overwrite any files if they already exist in the ruby directory !

Now its time to try it out again:

irb(main):001:0> require 'postgres'
=> true

Voila ! We have a native postgres client library installed and can use the advanced features like large object access.

This entry was posted in postgresql, ruby on rails. Bookmark the permalink.

2 Responses to Installing native Postgres gem for ruby

  1. Mark Carranza says:

    postgresql-8.3.3-1 required:
    replacing ssleay32.dll, libeay32.dll
    adding: libintl3.dll, k5sprt32.dll, gssapi32.dll.
    No problems yet…

  2. BaldDonkeys says:

    I had to add all of the dll’s on Postgres installation but it worked.

Leave a Reply