无法安装pg gem

Tho*_*ann 4 gem bundler pg

我花了好几个小时试图找出它为什么不起作用后终于设法得到'pg'宝石安装...

最后我进入了sudo env ARCHFLAGS="-arch x86_64" gem install pg -v 0.12.2 -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config一个像魅力一样的工作.但是现在我尝试捆绑时仍然有同样的错误 - 所以我猜我没有真正解决问题?无论如何,这bundle install是在说什么:

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

            /Users/thomas/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb --with-pg-config=/usr/pgsql-9.2/bin/pg_config
    Using config values from /usr/pgsql-9.2/bin/pg_config
    sh: /usr/pgsql-9.2/bin/pg_config: No such file or directory
    sh: /usr/pgsql-9.2/bin/pg_config: No such file or directory
    checking for libpq-fe.h... yes
    checking for libpq/libpq-fs.h... yes
    checking for PQconnectdb() in -lpq... yes
    checking for PQconnectionUsedPassword()... yes
    checking for PQisthreadsafe()... yes
    checking for PQprepare()... yes
    checking for PQexecParams()... yes
    checking for PQescapeString()... yes
    checking for PQescapeStringConn()... yes
    checking for PQgetCancel()... yes
    checking for lo_create()... yes
    checking for pg_encoding_to_char()... yes
    checking for PQsetClientEncoding()... yes
    checking for rb_encdb_alias()... yes
    checking for rb_enc_alias()... yes
    checking for struct pgNotify.extra in libpq-fe.h... yes
    checking for unistd.h... yes
    checking for ruby/st.h... yes
    creating extconf.h
    creating Makefile

make
    compiling compat.c
    compiling pg.c
    pg.c: In function ‘pgconn_wait_for_notify’:
    pg.c:2117: warning: ‘rb_thread_select’ is deprecated (declared at /Users/thomas/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/intern.h:380)
    pg.c: In function ‘pgconn_block’:
    pg.c:2592: warning: format not a string literal and no format arguments
    pg.c:2598: warning: ‘rb_thread_select’ is deprecated (declared at /Users/thomas/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/intern.h:380)
    pg.c:2607: warning: format not a string literal and no format arguments
    linking shared-object pg_ext.bundle
    ld: warning: directory not found for option '-L-Wl,-undefined,dynamic_lookup'
    Undefined symbols for architecture x86_64:

....

    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    make: *** [pg_ext.bundle] Error 1
Run Code Online (Sandbox Code Playgroud)

我认为问题是bundler尝试使用另一个postresql安装(我已经删除)的pg_config来安装gem.有没有办法确保捆绑器使用正确的路径?

Nee*_*pta 10

我被捆绑安装了3天.试着添加env ARCHFLAGS =" - arch x86_64"gem install pg - --with-pg-config =/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config

我能够看到pg gem在这个命令之后安装,但它仍然没有从bundle install安装,这很痛苦,因为我知道在Gemfile中写什么除了'宝石'pg'

最终对我有用的是找到我的pg_config在/Library/PostgreSQL/9.3/bin/pg_config中,默认情况下,Gemfile bundle install在/ usr/local/bin/pg_config中查找

我刚刚运行了以下命令并且发生了魔法.bundle config build.pg --with-pg-config =/Library/PostgreSQL/9.3/bin/pg_config