pg gem安装错误-lion osx、bundler和rvm



我花了太多时间试图解决这个问题。

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

Xcode 4.2.1已安装

RVM安装

当我设置我的环境时,我终于进行了捆绑安装,但它在尝试创建PGgem时失败了。

我使用macports安装了postgresql(不知道它预装在lion中)。以下说明如下:http://benscheirman.com/2010/06/installing-postgresql-for-rails-on-mac-os-x在尝试安装pg gem:时遇到了更多错误

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.

我不停地找斯塔克弗流,几乎什么都试过了。

我删除了macports版本,然后决定尝试用自制软件安装:

"brew install 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"类型的解决方案,但似乎没有任何区别。

有什么想法我应该从哪里开始吗?

我不熟悉Brew,但您调用的pg_config似乎不是用于配置pg.的

因此,请尝试将/usr/local/Cellar/postgresql/9.12/bin(期望有pg_config)包含到路径中,然后重试。

实际上,输出显示"使用/usr/local/bin/pg_config中的配置值"它应该是Brew路径中的pg_config。我想它在/usr/local/Cellar/postgresql/9.12/bin.

这可能会有所帮助:https://plus.google.com/104769575749979987265/posts/CVdrNMZYU9R

不管怎样,它对Linux也是如此。

最新更新