简体   繁体   English

Lion,RVM,Postgresql和PG Gem

[英]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. 我试图将Rails 3.0.x应用程序升级到3.1,但遇到一些问题:Heroku(托管我的应用程序)要求我使用其Cedar堆栈并在我的gemfile中包含“ PG” gem。 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. 我已经看到人们在安装这个gem时有很多问题,因为它似乎不知道在哪里可以找到Postgresql安装。

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. 我知道我安装Postgresql的选项可能是MacPorts,一键安装程序(来自其网站),自制软件,可能还有一些我不知道的选项。

So I guess my question is, which of these methods should I use to install Postgresql (on Lion)? 所以我想我的问题是,应该使用以下哪种方法来安装Postgresql(在Lion上)? Then, how would I get the PG gem to install w/ RVM without it complaining that it cannot find my postgresql install? 然后,我如何让PG gem通过RVM进行安装而又不会抱怨找不到我的postgresql安装?

I've simply installed PosgreSQL using homebrew and then did a bundle install for my project which used the pg gem. 我只是使用homebrew安装了PosgreSQL,然后为使用pg gem的项目bundle installbundle install homebrew Works like a charm. 奇迹般有效。 And yes, I run RVM. 是的,我运行RVM。

In my experience, the "one-click" installer works best, though I'd imagine Homebrew's is probably fine as well. 以我的经验,“一键式”安装程序效果最好,尽管我认为Homebrew的安装程序也可能很好。 The "one-click" version on Lion is the version I use when doing development and testing on the pg library. Lion上的“一键式”版本是我在pg库上进行开发和测试时使用的版本。 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. 您将要避免通过Macports安装它,除非您确保将它与Ruby的OpenSSL扩展名的同一版本的OpenSSL链接在一起。 If they're linked against different versions, you risk segfaulting . 如果将它们链接到不同的版本,则可能存在segfaulting的风险。

The 'pg_config' binary is the critical piece of getting the 'pg' gem to install. “ pg_config”二进制文件是安装“ pg” gem的关键部分。 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. 如果找不到它(并且您没有使用--with-pg-config选项将其指向某个),它将尝试猜测在何处安装了东西,但这并不总是可行。 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. 同样,与链接到共享库的任何扩展一样,您需要确保以与Ruby相同的体系结构编译该扩展。 Setting 'ARCHFLAGS' to '-arch x86_64' usually works on Lion. 将“ ARCHFLAGS”设置为“ -arch x86_64”通常可在Lion上使用。

See the MacOS X README for more details. 有关更多详细信息,请参见MacOS X自述文件

If you still are having trouble, feel free to mail me, as I'd like to make 'pg' easier to install for everyone. 如果您仍然遇到问题,请随时发邮件给我,因为我想让每个人都可以轻松安装'pg'。 I'm working on better diagnostics for when things go wrong, but it's hard to anticipate every way the build could go wrong. 我正在为发生错误的情况进行更好的诊断,但是很难预测构建可能出错的所有方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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