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!
pg gem install on Mac OS Lion with rvm
The error message ("You have to install development tools first.") says it all. Install Xcode first, and then try installing the pg gem.
Also, you don't have to install a third-party PostgreSQL on Lion, as it's already included.
unable to install pg gem
Answered here:
Can't install pg gem on Windows
There is no Windows native version of
latest release of pg (0.10.0) released
yesterday, but if you install 0.9.0 it
should install binaries without
issues.
How do I get gem install to work on OS X Lion with Ruby 1.8.7 without seg faulting?
Make sure your rvm is up to date: rvm get latest
And then run this: rvm uninstall 1.8.7 && CC=/usr/bin/gcc-4.2 rvm install 1.8.7
Basically you must tell rvm which gcc compiler to use (CC=/usr/bin/gcc-4.2
)
Then you should be able to install the pg gem as normal.
Trouble installing pg gem
Not sure which of the following steps finally cleared this issue up. But as mu is too short mentioned, the problem was mixing 32bit and 64bit binaries.
- 1st, I installed this 64-bit version of PostgreSQL
2nd, I uninstalled any old Homebrew OpenSSL installation
$ brew uninstall openssl
3rd, I installed the 64-bit version of OpenSSL with Homebrew
$ brew install --64-bit openssl
Lastly, when installing the pg gem, I changed the LDFLAGS to point to the 64-bit version of OpenSSL
$ gem install pg -- --with-ldflags='-L/usr/local/Cellar/openssl/0.9.8s'
Error install pg gem
You probably need to install the postgresql development libraries first, using one of (homebrew, macports, fink). I personally still like macports, but homebrew seems to be growing more popular. If that still doesn't work, you may need to pass some flags to the 'gem install' command to tell it where to find those libraries.
Failing installing pg gem, mkmf.rb can't find header files for ruby (Mac OSX 10.6.5)
Generally the gem bundles for Postgres want to know where pg_config
is hiding so they can ask about the Postgres installation.
Use locate pg_config
to see if your Mac knows where it's hiding.
I installed a copy of Postgres using mappstack, so my Mac says there's a copy at:
/Applications/mappstack-1.2-3/postgresql/bin/pg_config
and another at:
/Library/PostgreSQL/9.0/bin/pg_config
I don't remember installing the one at /Library/PostgreSQL/9.0
, so it might have been preinstalled by Snow Leopard, or I did it when under the influence of too much work, possibly using the Postgres installer from EnterpriseDB.
Once you've found the location of pg_config
try adding that directory to the start of your PATH and then rerun the gem install.
Or use:
export SQL_PATH=/Library/PostgreSQL/9.0
gem install pg -- --with-pg-config=$SQL_PATH/bin/pg_config
and try installing. If either of those work you're done. Otherwise...
The next thing the installers might want are access to the Postgres headers, so you look in the parent of the bin
directories, and see if you can find an include
directory.
After that, look in that directory for a lib
directory. Once you know those locations you should have all you need to set your environment variables to let the installer complete. You'll need to read the README
or INSTALL
file of the installer and see what needs to be set up. You'll be configuring:
export include_dir=$SQL_PATH/include/
export lib_dir=$SQL_PATH/lib/
gem install pg -- --with-pgsql-include-dir=$include_dir --with-pgsql-lib-dir=$lib_dir
Hopefully that'll all help. I have Rails 3 and my Postgres running fine, using the mappstack Postgres and the EnterpriseDB versions, so the above info should get you there.
Related Topics
How to Enable C Extension Support in Jruby
How to Detect Certain Unicode Characters in a String in Ruby
Why Is _File_ Uppercase and _Dir_ Lowercase
Ruby 'Encode': "\Xc3" from Ascii-8Bit to Utf-8 (Encoding::Undefinedconversionerror)
Ruby 1.9 Hash with a Dash in a Key
Escaping Single and Double Quotes in a String in Ruby
Why Did Matz Choose to Make Strings Mutable by Default in Ruby
Ruby Net::Http - Following 301 Redirects
Do Ruby 'Require' Statements Go Inside or Outside the Class Definition
Differencebetween Link_To, Redirect_To, and Render
Rails - Sort by Join Table Data
Ruby: Dynamically Generate Attribute_Accessor
Comparing Two Arrays Ignoring Element Order in Ruby