无法安装pg gem

编程入门 行业动态 更新时间:2024-10-28 08:21:34
本文介绍了无法安装pg gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

最后,我花了数小时试图弄清楚为什么它不能正常工作,终于设法得到'pg'gem install ...

最后我输入了 sudo env ARCHFLAGS = - arch x86_64gem install pg -v 0.12.2 - --with-pg-config = / Applications / Postgres.app / Contents / MacOS / bin / pg_config

安装pg(0.12 .2) Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。 /Users/thomas/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb --with-pg-config = / usr / pgsql-9.2 / bin / pg_config 使用/usr/pgsql-9.2/bin/pg_config中的配置值 sh:/usr/pgsql-9.2/bin/pg_config:没有这样的文件或目录 sh:/ usr / pgsql -9.2 / bin / pg_config:没有这样的文件或目录检查libpq-fe.h ...是检查libpq / libpq-fs.h ...是检查PQconnectdb()in -lpq ...是检查PQconnectionUsedPassword()...是检查PQisthreadsafe()...是检查PQprepare()...是检查PQexecParams()...是检查PQescapeString()...是检查PQescapeStringConn()...是检查PQgetCancel()...是检查lo_create()...是检查pg_encoding_to_char()...是检查PQsetClientEncoding()...是检查rb_encdb_alias()。 ..是登记g为rb_enc_alias()...是在libpq-fe.h中检查struct pgNotify.extra ...是检查unistd.h ...是检查ruby / st.h ...是创建extconf.h 创建Makefile make 编译compat.c 编译pg.c pg.c:函数'pgconn_wait_for_notify': pg.c:2117:警告:'rb_thread_select'已被弃用(在/Users/thomas/.rvm/rubies/ruby-1.9.3-p392/include/处声明) ruby-1.9.1 / ruby​​ / intern.h:380) pg.c:在函数'pgconn_block'中: pg.c:2592:warning:格式不是字符串和格式参数 pg.c:2598:警告:'rb_thread_select'已弃用(在/Users/thomas/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/intern.h中声明)。 :380) pg.c:2607:警告:格式不是字符串字面,也不是格式参数链接共享对象pg_ext.bundle ld:warning:找不到选项的目录' - L-WL,-undefined,DYNAM ic_lookup'架构x86_64的未定义符号: .... ld:架构x86_64未找到符号 collect2:ld返回1退出状态 make:*** [pg_ext.bundle]错误1

I认为问题在于bundler试图使用来自另一postresql安装(我已经删除)的pg_config来安装gem。有没有什么方法可以确保bundler使用正确的路径?

解决方案

我被捆绑安装了3天。尝试一切,比如添加env ARCHFLAGS = - arch x86_64gem install pg - --with-pg-config = / usr / local / Cellar / postgresql / 9.3.5_1 / bin / pg_config

我能够看到pg gem在这个命令后被安装,但仍然不是从bundle install安装的,这是一种痛苦,因为我知道要在Gemfile中写入什么,除了gem'pg'

终于为我工作的东西是发现我的pg_config位于/Library/PostgreSQL/9.3/bin/pg_config,默认情况下,Gemfile捆绑安装在/ usr / local / bin / pg_config

我刚刚运行以下命令并发生了魔法。 bundle config build.pg --with-pg-config = / Library / PostgreSQL / 9.3 / bin / pg_config I finally managed to get the 'pg' gem install after spending hours trying to figure out why it's not working...

at the end I entered sudo env ARCHFLAGS="-arch x86_64" gem install pg -v 0.12.2 -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config which worked like a charm. But now I still have the same error when I try bundler - so I guess I didn't really solve the problem? Anyway, here's what bundle install is saying:

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

I think the problem is that bundler tries to install the gem using the pg_config from another postresql installation (which I had removed). Is there any way to ensure that bundler uses the right path?

解决方案

I was stuck on my bundle install for 3 days. Tried Everything like adding env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config

I was able to see pg gem getting installed after this command but still it was not installing from bundle install, which was a pain because I dint know what to write in Gemfile except gem 'pg'

The thing which finally worked for me was to find that my pg_config was in /Library/PostgreSQL/9.3/bin/pg_config and by default the Gemfile bundle install looks in /usr/local/bin/pg_config

I just ran the following command and magic happened. bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config

更多推荐

无法安装pg gem

本文发布于:2023-10-13 20:17:23,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:pg   gem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!