Tad Thorley Avatar

20 Notes

Installing a ruby gem for postgresql

I do it infrequently so I can never remember which gem to install or all of the how’s. I figured I would document it so I can remember next time.

For my purposes, the postgres installer was fine, which I found here: http://www.postgresql.org/download/macosx (I’m installing on OS X, obviously)

After I installed the database, I searched for a gem. There are a few to choose from, but the “pg” gem seems to be the popular one (and gets updated frequently). You can check it out here: http://rubygems.org/gems/pg

It’s not as easy as “gem install pg”.  After doing some searching, I discovered I needed to set “ARCHFLAGS”. The command “file `which ruby`” reminded me what I needed to set it to.

Next, I needed to know where compile-relevant files were located. I added “export PATH=/Library/PostgreSQL/9.0/bin:$PATH” to my .profile so I could just run “pg_config” from the command line and see where everything was.

I then ran:

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-include=/Library/PostgreSQL/9.0/include --with-pg-lib=/Library/PostgreSQL/9.0/lib

which installed it successfully. Hope this helps.

Replies

Likes

  1. tadthorley posted this

 

Reblogs