Ошибка установки pg gem

Чтобы развернуть мое приложение rails на heroku, я внес изменения в свой Gemfile, добавив

gem 'pg'

Однажды я сделал

bundle install

Я получаю следующую ошибку -

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.

Я предположил, что на моем компьютере не был установлен PostgreSQL, и поэтому загрузил его без толку. Я попробовал пару других вариантов и снова выполнил следующую команду с такими же ошибками.

gem install pg

person Aniruddha    schedule 28.12.2013    source источник


Ответы (4)


Разобрался с этим делом.

Поскольку у меня уже был установлен PostgreSQL.app. Дал следующую команду -

gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
person Aniruddha    schedule 28.12.2013
comment
В моем случае (с Postgres.app 9.3.2.0) правильной командой была: gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config - person Nacho L.; 16.09.2014
comment
Вариант этого работал для меня. Мне пришлось запустить env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config — просто убедитесь, что вы указали правильную версию PG. - person cpursley; 09.01.2015
comment
Обновление для Postgres.app 9.4 gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config - person rich; 15.01.2015
comment
это работает здесь, но кто-нибудь может сказать, зачем это делать ?? - person LiangWang; 07.04.2015

Это работает => env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config

person user3421170    schedule 02.05.2015

У вас есть библиотеки разработки postgres?

person Community    schedule 28.12.2013
comment
sudo apt-get установить libpq-dev - person ; 29.12.2013
comment
Каноническая установка ruby ​​устанавливается с помощью rvm и postgress с помощью postgres.app или через homebrew. проверьте ссылку выше. также проверьте rvm, если у вас по-прежнему возникают проблемы. - person ; 29.12.2013
comment
У меня уже достаточно проблем с Homebrew. [stackoverflow.com/questions/19532394/error-installing-homebrew]< /а> - person Aniruddha; 29.12.2013

Я удалил, а затем переустановил postgresql. Затем я установил pg -v '0.17.1'. После этого я запустил бандл. Это сработало.

person user3403529    schedule 08.04.2015