gem install pg doesn't work on OSX Lion gem install pg doesn't work on OSX Lion ruby ruby

gem install pg doesn't work on OSX Lion


I finally found the cause of the problem! Though I am still uncertain how this problem came about.

Look at the contents of the mkmf.log file that is created when my install command fails (see my original post). It logs an attempt to run the following command

/usr/bin/gcc-4.2 ...and so on...

There is no /usr/bin/gcc-4.2 on my system. There is a gcc, which is symbolically linked to llvm-gcc-4.2. My solution was to create another symbolic link

sudo ln -s llvm-gcc-4.2 gcc-4.2 

After making this link, my gem install pg command worked without any problems.

I found the solution to this problem on the Frozen Canuck blog in the post Error Installing Ruby Gem with C Extension. He speculates that the problem can be caused by conflicting versions of XCode. whatever the cause, my eternal thanks!


On OS X Mavericks

sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2

works.


I had a similar issue. Following an answer by bobfet1 for a similar issue I was able to get the gem installed by:

sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config