Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Tim Smith
Tim Smith
11,164 Points

Treebook Heroku/Postgres Problem (long post)

Hi everyone,

I am trying to deploy my treebook app to Heroku and am getting and an error. I have followed the tutortial and added postgres to my gem file but when I try to "git push heroku master" I get the following error:

****** Output ****** id: treebook $ git push heroku master Counting objects: 297, done. Delta compression using up to 4 threads. Compressing objects: 100% (271/271), done. Writing objects: 100% (297/297), 109.43 KiB | 0 bytes/s, done. Total 297 (delta 116), reused 0 (delta 0)

-----> Ruby/Rails app detected -----> Using Ruby version: ruby-2.0.0 -----> Installing dependencies using Bundler version 1.3.2 New app detected loading default bundler cache Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment You are trying to install in deployment mode after changing your Gemfile. Run bundle install elsewhere and add the updated Gemfile.lock to version control. You have added to the Gemfile: * pg Bundler Output: You are trying to install in deployment mode after changing your Gemfile. Run bundle install elsewhere and add the updated Gemfile.lock to version control.

   You have added to the Gemfile:
   * pg

! ! Failed to install gems via Bundler. !

! Push rejected, failed to compile Ruby/Rails app

To git@heroku.com:aqueous-headland-9388.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:aqueous-headland-9388.git'


It tells me to 'bundle install' and when I do that I get:

****** Output ****** ... Using devise (3.1.1) Using jquery-rails (3.0.4) Installing pg (0.17.0) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/tithos/.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 --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/tithos/.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/tithos/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.0 for inspection. Results logged to /Users/tithos/.rvm/gems/ruby-2.0.0-p247/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.


When I try gem install pg -v '0.17.0' I get:

****** Output ****** id: treebook $ gem install pg -v '0.17.0' Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.

/Users/tithos/.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 --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/tithos/.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/tithos/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.0 for inspection. Results logged to /Users/tithos/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.0/ext/gem_make.out


I am totally lost. Any help would be great.

1 Answer

Did you wrap 'pg' in Gemfile?

group :production do
  gem 'pg'
end

Then do:

bundle install --without production