简体   繁体   中英

Lion, RVM, Postgresql, and the PG Gem

I'm attempting to upgrade me Rails 3.0.x application to 3.1 but I'm running into some problems: Heroku (which my app is hosted on) requires that I use their Cedar stack & include the "PG" gem in my gemfile. I've seen that people have quite a lot of problems when installing this gem because it doesn't seem to know where to find the Postgresql install at.

I know that my options for installing Postgresql are probably MacPorts, One Click Installer (from their website), Homebrew, and possibly some that I'm not aware of.

So I guess my question is, which of these methods should I use to install Postgresql (on Lion)? Then, how would I get the PG gem to install w/ RVM without it complaining that it cannot find my postgresql install?

I've simply installed PosgreSQL using homebrew and then did a bundle install for my project which used the pg gem. Works like a charm. And yes, I run RVM.

In my experience, the "one-click" installer works best, though I'd imagine Homebrew's is probably fine as well. The "one-click" version on Lion is the version I use when doing development and testing on the pg library. You'll want to avoid installing it via Macports unless you ensure that it is linked against the same version of OpenSSL that your Ruby's OpenSSL extension is. If they're linked against different versions, you risk segfaulting .

The 'pg_config' binary is the critical piece of getting the 'pg' gem to install. If it can't find that (and you don't point it at one using the --with-pg-config option), it will try to guess where stuff is installed, but that doesn't always work. Also, as with any extension that links against a shared library, you need to ensure that you compile the extension with the same architecture/s as your Ruby. Setting 'ARCHFLAGS' to '-arch x86_64' usually works on Lion.

See the MacOS X README for more details.

If you still are having trouble, feel free to mail me, as I'd like to make 'pg' easier to install for everyone. I'm working on better diagnostics for when things go wrong, but it's hard to anticipate every way the build could go wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM