简体   繁体   English

安装pg gem时出错

[英]Error installing pg gem

In order to deploy my rails app to heroku, I made change to my Gemfile by adding 为了将rails应用程序部署到heroku,我添加了对Gemfile的更改

gem 'pg'

Once I did 一旦我做了

bundle install

I am getting following error - 我收到以下错误-

Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1) 
Using i18n (0.6.9) 
Using minitest (4.7.5) 
Using multi_json (1.8.2) 
Using atomic (1.1.14) 
Using thread_safe (0.1.3) 
Using tzinfo (0.3.38) 
Using activesupport (4.0.0) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.0) 
Using mime-types (1.25.1) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.0) 
Using activemodel (4.0.0) 
Using activerecord-deprecated_finders (1.0.3) 
Using arel (4.0.1) 
Using activerecord (4.0.0) 
Using bundler (1.3.5) 
Using coffee-script-source (1.6.3) 
Using execjs (2.0.2) 
Using coffee-script (2.2.0) 
Using thor (0.18.1) 
Using railties (4.0.0) 
Using coffee-rails (4.0.1) 
Using hike (1.2.3) 
Using jbuilder (1.5.3) 
Using jquery-rails (3.0.4) 
Using json (1.8.1) 
Installing pg (0.17.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/aniruddhabarapatre1/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/aniruddhabarapatre1/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/


Gem files will remain installed in /Users/aniruddhabarapatre1/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.1 for inspection.
Results logged to /Users/aniruddhabarapatre1/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.1/ext/gem_make.out

An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

I assumed I didn't had PostgreSQL installed on my computer and hence downloaded it to no use. 我以为我没有在计算机上安装PostgreSQL,因此没有下载它。 I tried couple of other options and ran following command with similar errors again. 我尝试了其他几个选项,然后再次执行以下命令,并出现类似的错误。

gem install pg

Got this thing figured out. 弄明白了这件事。

Since I had PostgreSQL.app already installed. 由于我已经安装了PostgreSQL.app。 Gave following command - 发出以下命令-

gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config

这有效=> env ARCHFLAGS =“-arch x86_64” gem install pg---with-pg-config = / Applications / Postgres.app / Contents / Versions / 9.4 / bin / pg_config

您有postgres开发库吗?

I uninstalled then reinstalled postgresql. 我先卸载后重新安装了postgresql。 Then I installed pg -v '0.17.1'. 然后我安装了pg -v'0.17.1'。 After that I ran bundle. 在那之后我跑了捆绑。 It worked. 有效。

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

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