I've tried bundling my Rails app on my Mac at work. At home it works fine and I've managed it solve it myself previously but this time no matter what I try nothing appears to be working to resolve it.

The error I receive when running bundle/bundle install is the following:

Installing pg (0.17.0) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/notrab/.rbenv/versions/2.0.0-p0/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 --without-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/notrab/.rbenv/versions/2.0.0-p0/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/notrab/Sites/Integrity/vendor/bundle/gems/pg-0.17.0 for inspection.

Results logged to /Users/notrab/Sites/Integrity/vendor/bundle/gems/pg-0.17.0/ext/gem_make.out

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

I've obviously tried running

gem install pg -v '0.17.0' and it says it was successful but bundling again shows the same error.

I have also tried running

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

Which is outlined in the documentation http://postgresapp.com/documentation but the same error occurs when I try to bundle.

I'm going round in circles and don't know how to resolve it.

My Gemfile looks like:

group :development, :test do
    gem "better_errors"
    gem 'meta_request'
    gem 'binding_of_caller'
    gem 'sqlite3'
end

group :production do
    gem 'pg'
end

Many thanks,

Jamie

有帮助吗?

解决方案

Have you tried adding export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" to your .bash_profile?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top