Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Installing PG gem on OS X - failure to build native extension

Same error for me and I didn't experience it until I downloaded OS X 10.9 (Mavericks). Sigh, another OS upgrade headache.

Here's how I fixed it (with homebrew):

  • Install another build of Xcode Tools (typing brew update in the terminal will prompt you to update the Xcode build tools)
  • brew update
  • brew install postgresql

After that gem install pg worked for me.


If you are using Ubuntu try to install following lib file

sudo apt-get install libpq-dev

and then

gem install pg

worked for me.


I am using OS X Mavericks (version 10.9)

and when I run the above I got the following message: If builds of PostgreSQL 9 are failing and you have version 8.x installed.

So I run the following command:

ARCHFLAGS="-arch x86_64" gem install pg

and this worked for me, I hope this helps someone :)


Ok I also had this problem (psql is v 9.3.0 and ruby is v 2.1.2) and the solution that worked for me was setting the bundle config settings first:

bundle config build.pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

This answer finally helped me figure it out: https://stackoverflow.com/a/9235107/3546680


I tried everything for hours but the following finally fixed it (I'm on OS X 10.9.4):

  1. Install Xcode command line tools (Apple Developer site)
  2. brew uninstall postgresql
  3. brew install postgresql
  4. ARCHFLAGS="-arch x86_64" gem install pg