安装pg gem时出错

Ani*_*dha 1 macos gem heroku pg ruby-on-rails-4

为了将我的rails应用程序部署到heroku,我通过添加更改了我的Gemfile

gem 'pg'
Run Code Online (Sandbox Code Playgroud)

我曾经做过

bundle install
Run Code Online (Sandbox Code Playgroud)

我收到以下错误 -

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.
Run Code Online (Sandbox Code Playgroud)

我以为我没有在我的计算机上安装PostgreSQL,因此下载它没用.我尝试了其他几个选项并再次使用类似错误运行以下命令.

gem install pg
Run Code Online (Sandbox Code Playgroud)

Ani*_*dha 9

弄明白这件事.

因为我已经安装了PostgreSQL.app.给出以下命令 -

gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
Run Code Online (Sandbox Code Playgroud)

  • 更新Postgres.app 9.4`创业板安装PG - --with-PG-配置= /应用/ Postgres.app /内容/版本/ 9.4 /斌/ pg_config` (2认同)