无法安装PG宝石(Cannot install pg gem)

2019-08-17 08:22发布

我终于设法得到“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

我认为这个问题是捆绑试图安装使用来自另一个postresql安装pg_config(我已经删除)的宝石。 有没有什么办法,以确保打捆使用了正确的道路?

Answer 1:

我被困在我的包安装3天。 想尽一切如添加ENV ARCHFLAGS = “ - 拱x86_64的” 创业板安装PG - --with-PG-配置=在/ usr /本地/库/ PostgreSQL的/ 9.3.5_1 /斌/ pg_config

我能看到越来越安装此命令后,皮克宝石但仍没有从安装包安装,这是一个痛苦,因为我不力知道在Gemfile中除了写宝玉“PG”

这终于为我工作的事就是发现我pg_config是/Library/PostgreSQL/9.3/bin/pg_config,默认情况下的Gemfile捆绑安装在/ usr / local / bin目录/ pg_config外观

我只是跑以下命令,奇迹发生了。 束的配置build.pg --with-PG-配置= /库/ PostgreSQL的/ 9.3 / bin中/ pg_config



Answer 2:

一些修正。 对于那些谁使用自制安装的Postgres。

1)写出下面的行放在〜/ .bash_profile中

出口ARCHFLAGS = “ -拱x86_64的”

2)重新启动控制台

3)执行以下命令

捆绑配置build.pg --with-PG-配置=在/ usr /本地/库/ PostgreSQL的/ 9.3.5_1 /斌/ pg_config(这必须是您的PG配置地址有差别,可为每个取决于Postgres的版本)

4)通过运行该命令安装PG一旦本地

须藤ENV ARCHFLAGS = “ -拱x86_64的”创业板安装PG - --with-PG-配置=在/ usr /本地/库/ PostgreSQL的/ 9.3.5_1 /斌/ pg_config

5) 捆绑安装



文章来源: Cannot install pg gem
标签: gem bundler pg