简体   繁体   English

Bundler尝试并且无法安装已成功安装的pg gem

[英]Bundler tries and fails to install the pg gem, which is already successfully installed

I've got the pg gem installed: 我已经安装了pg gem:

$ gem install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.15.1
1 gem installed

$ gem list | grep pg
pg (0.15.1, 0.14.1)

However whenever i try to run 'bundle install' on my rails app, it tries to install pg again, and fails: 但是每当我尝试在我的rails应用程序上运行'bundle install'时,它会再次尝试安装pg,并失败:

Installing pg (0.15.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
...

How can i get bundler to simply use my already-installed version of pg? 我怎样才能让Bundler简单地使用我已经安装的pg版本? My Gemfile.lock has: 我的Gemfile.lock有:

pg (0.15.1)

Which matches the version i can see with gem list. 哪个匹配我可以看到宝石列表的版本。 I'm not sure what's wrong here. 我不确定这里有什么问题。

So i installed the postgresSQL installer from: 所以我安装了postgresSQL安装程序:

http://www.enterprisedb.com/products-services-training/pgdownload#osx

Then i did: 然后我做了:

bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.2/bin/pg_config

Then it worked :) 然后它工作:)

Use this command "bundle install --without production" . 使用此命令“bundle install --without production”。

It worked for me. 它对我有用。 In my case, I cloned the git repository of rails app, and tried bundle update, but failed and got the same message. 在我的情况下,我克隆了rails app的git存储库,并尝试了bundle更新,但是失败并得到了相同的消息。

That command prevents the local installation of production gems such as pg and rails_12factor gems. 该命令阻止了本地安装生产宝石,例如pg和rails_12factor gems。

命令“bundle install --without production”对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM