使用rvm,postgres 9.0,ruby 1.9.2-p136在64位Snow Leopard上安装pg gem的问题

Guy*_*rgo 5 ruby postgresql gem rvm pg

我想为Heroku构建一个Rails 3应用程序.他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres 9.0.现在我需要一个postgres gem,并且一致认为,出于性能原因,你需要pg gem.但是当我尝试通过rvm下的gem install安装pg时,我完全感到困惑.

我已经非常明确地指定了所有postgres目录的位置,但仍然无法完成安装:

$ env ARCHFLAGS='-arch x86_64' gem install pg -- \
   --with-pg-config=/opt/local/var/db/postgresql90/defaultdb/postgresql.conf \
   --with-pg-include=/opt/local/include/postgresql90/ \
   --with-pg-lib=/opt/local/lib/postgresql90/

Using config values from /opt/local/var/db/postgresql90/defaultdb/postgresql.conf
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/guy/.rvm/ruby-1.9.2-p136/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include=${pg-dir}/include
    --with-pg-lib=${pg-dir}/lib
    --with-pg-config
extconf.rb:24:in ``': Exec format error - /opt/local/var/db/postgresql90/defaultdb/postgresql.conf --includedir (Errno::ENOEXEC)
    from extconf.rb:24:in `<main>'
Run Code Online (Sandbox Code Playgroud)

有人有任何想法吗?我很困惑.家伙

mu *_*ort 6

我认为你的问题就在这里:

--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/postgresql.conf
Run Code Online (Sandbox Code Playgroud)

--with-pg-config开关可能想知道那里的pg_config脚本,而不是人postgresql.conf的.你应该在pg_config某个地方/opt/local/bin(可能)下面有一个脚本,它应该产生一大堆这样的东西:

BINDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/bin
DOCDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/share/doc
HTMLDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/share/doc
INCLUDEDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/include
PKGINCLUDEDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/include
INCLUDEDIR-SERVER = /Users/mu/Developer/Cellar/postgresql/9.0.1/include/server
LIBDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/lib
PKGLIBDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/lib
...
Run Code Online (Sandbox Code Playgroud)

当你运行它.该pg_config脚本告诉您(或任何要求的人)各种头文件和库的位置以及需要哪些编译器标志.

"Exec格式错误"错误消息是赠送.听起来你正在尝试执行操作系统不知道如何执行的东西,我不希望OSX知道如何执行某些任意配置文件.