2012-02-01 102 views
0

我花了太多的时间试图解决这个问题。pg gem安装错误 - 狮子osx,bundler和rvm

我重新格式化了我的电脑 - 干净的雪豹,比立即升级到狮子。

的Xcode 4.2.1安装

RVM安装

当我安装我的环境我终于得到了捆绑安装,并且它没有试图创建PG宝石。

我已经安装postgresql使用macports(不知道它预装在狮子)。这里以下说明:HTTP://benscheirman.com/2010/06/installing-postgresql-for-rails-on-mac-os-x跑进更多的错误尝试安装PG宝石:

Installing pg (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /Users/me/.rvm/rubies/ruby-1.8.7-p357/bin/ruby extconf.rb 
checking for pg_config... yes 
Using config values from /usr/local/bin/pg_config 
checking for libpq-fe.h... no 
Can't find the 'libpq-fe.h header 
*** 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/sling31/.rvm/rubies/ruby-1.8.7-p357/bin/ruby 
    --with-pg 
    --without-pg 
    --with-pg-dir 
    --without-pg-dir 
    --with-pg-include 
    --without-pg-include=${pg-dir}/include 
    --with-pg-lib 
    --without-pg-lib=${pg-dir}/lib 
    --with-pg-config 
    --without-pg-config 
    --with-pg_config 
    --without-pg_config 


Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.8.7-p357/gems/pg-0.12.0 for inspection. 
Results logged to /Users/me/.rvm/gems/ruby-1.8.7-p357/gems/pg-0.12.0/ext/gem_make.out 
An error occured while installing pg (0.12.0), and Bundler cannot continue. 
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling. 

我不停地搜索了stackoverflow,几乎试过了一切。

我删除了MacPorts的版本,然后决定尝试用自制安装:

“酿造安装PostgreSQL”

pg_config给我:

BINDIR = /usr/local/Cellar/postgresql/9.1.2/bin 
DOCDIR = /usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql 
HTMLDIR = /usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql 
INCLUDEDIR = /usr/local/Cellar/postgresql/9.1.2/include 
PKGINCLUDEDIR = /usr/local/Cellar/postgresql/9.1.2/include 
INCLUDEDIR-SERVER = /usr/local/Cellar/postgresql/9.1.2/include/server 
LIBDIR = /usr/local/Cellar/postgresql/9.1.2/lib 
PKGLIBDIR = /usr/local/Cellar/postgresql/9.1.2/lib 
LOCALEDIR = /usr/local/Cellar/postgresql/9.1.2/share/locale 
MANDIR = /usr/local/Cellar/postgresql/9.1.2/share/man 
SHAREDIR = /usr/local/Cellar/postgresql/9.1.2/share/postgresql 
SYSCONFDIR = /usr/local/Cellar/postgresql/9.1.2/etc 
PGXS = /usr/local/Cellar/postgresql/9.1.2/lib/pgxs/src/makefiles/pgxs.mk 
CONFIGURE = '--disable-debug' '--prefix=/usr/local/Cellar/postgresql/9.1.2' '--enable-thread-safety' '--with-bonjour' '--with-gssapi' '--with-krb5' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-python' '--with-perl' '--with-ossp-uuid' '--datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql' '--docdir=/usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql' 'ARCHFLAGS='''-arch x86_64'''' 'CC=/usr/bin/llvm-gcc' 'CFLAGS=-O3 -w -pipe -march=core2 -msse4.1 -I/opt/local/include/ossp' 'LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib -L/opt/local/lib' 'LIBS=-luuid' 'CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include -I/usr/include/libxml2' 
CC = /usr/bin/llvm-gcc 
CPPFLAGS = -I/usr/local/Cellar/readline/6.2.2/include -I/usr/include/libxml2 -I/opt/local/include/libxml2 
CFLAGS = -O3 -w -pipe -march=core2 -msse4.1 -I/opt/local/include/ossp -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv 
CFLAGS_SL = 
LDFLAGS = -L/usr/local/Cellar/readline/6.2.2/lib -L/opt/local/lib -L/opt/local/lib -Wl,-dead_strip_dylibs 
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgport -lxslt -lxml2 -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm -luuid 
VERSION = PostgreSQL 9.1.2 

我尝试了所有的出口rvm_archflags的=“ - arch x86_64”类型的解决方案,但似乎没有任何区别。

任何想法,我应该开始?

+0

什么是自制错误?当你做'post info postgres'时它说什么? – Woahdae 2012-02-01 04:42:09

+0

或者您的意思是它在brew下正确安装,但仍不会构建gem扩展? – Woahdae 2012-02-01 04:43:12

回答

1

我不熟悉Brew,但它看起来像你调用的pg_config不是用来配置pg的。

因此,请尝试包括/usr/local/Cellar/postgresql/9.1.2/bin(希望有pg_config那里)到路径并重试。

实际上,输出显示“使用来自/ usr/local/bin/pg_config的配置值” 它应该是Brew路径中的pg_config。我想这是在/usr/local/Cellar/postgresql/9.1.2/bin。