无法安装pg gem[英] Cannot install pg gem

本文是小编为大家收集整理的关于无法安装pg gem的处理方法,想解了无法安装pg gem的问题怎么解决?无法安装pg gem问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我终于设法在花费时间尝试弄清楚为什么不起作用...

在最后,我输入了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

我认为问题是Bundler尝试使用来自另一个POStresQL安装(我已删除的PG_Config安装GEM.有没有办法确保Bundler使用正确的路径?

推荐答案

我被困在我的捆绑上安装3天.尝试了一切如添加enchflags =" - Arch X86_64"Gem Install Pg - - --with-pg-config =/usr/local/cellar/postgresql/9.3.5_1/bin/pg_config

我能够在此命令后看到pg gem已安装,但仍然没有从捆绑安装中安装,这是一个痛苦,因为我会知道除了GEM'PG'

之外的Gemfile中写了什么.

终于为我工作的事情是发现我的pg_config在/library/postgresql/9.3/bin/pg_config中,默认情况下,Gemfile Bundle安装在/usr/local/bin/pg_config

我只是运行以下命令,魔术发生了. bundle config build.pg --with-pg-config =/library/postgreesql/9.3/bin/pg_config

其他推荐答案

一些校正. 对于那些使用自制的人安装Postgres的人.

1)在〜/.bash_profile

中写下以下行

出口Archflags =" - arch x86_64"

2)重新启动控制台

3)执行以下命令

bundle config build.pg --with-pg-config =/usr/local/cellar/postgresql/9.3.5_1/bin/pg_config (这必须是您的PG配置地址,可能因Postgres版本而有所不同)

4)通过运行此命令,在本地安装pg

sudo enchflags =" - arch x86_64"Gem Install Pg - - --with-pg-config =/usr/local/cellar/postgresql/9.3.5_1/bin/pg_config

5) bundle安装

本文地址:https://www.itbaoku.cn/post/786632.html