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

General Discussion

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Postgres/Heroku Failures

I can't get postgres to run. I'm going to cry. I just want to deploy this app. I spent a week trying to figure out postgres in the summer and had to get someone else to do it. I can't understand their instructions, and the instructions on heroku and postgres.app are not getting me past the issue.

I need to install postgres. I have updated my gemfile and my database.yml file.


Gemfile: source 'https://rubygems.org'

Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails', '4.0.0'

Use sqlite3 as the database for Active Record

gem 'sqlite3'

Use SCSS for stylesheets

gem 'sass-rails', '~> 4.0.0'

Use Uglifier as compressor for JavaScript assets

gem 'uglifier', '>= 1.3.0'

Use CoffeeScript for .js.coffee assets and views

gem 'coffee-rails', '~> 4.0.0'

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem 'therubyracer', platforms: :ruby

Use jquery as the JavaScript library

gem 'jquery-rails'

Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks

gem 'turbolinks'

Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

gem 'jbuilder', '~> 1.2'

group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end

group :development, :test do gem 'rspec-rails', '~> 2.0' gem 'sqlite3' end

group :test do gem 'capybara', '~> 2.1.0' gem 'shoulda-matchers', '~> 2.4.0' end

group :production do gem 'rails_12factor' gem 'pg' end

ruby "2.1.0"

Use ActiveModel has_secure_password

gem 'bcrypt-ruby', '~> 3.0.0'

Use unicorn as the app server

gem 'unicorn'

Use Capistrano for deployment

gem 'capistrano', group: :development

Use debugger

gem 'debugger', group: [:development, :test]


Database.yml

SQLite version 3.x

gem install sqlite3

Ensure the SQLite 3 gem is defined in your Gemfile

gem 'sqlite3'

development: adapter: postgresql database: odot_dev host: localhost

Warning: The database defined as "test" will be erased and

re-generated from your development database when you run "rake".

Do not set this db to the same as development or production.

test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000

production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000


Here's the error:

Naomis-MacBook-Air:odot Naomi$ gem install pg -v '0.17.1' Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.

/Users/Naomi/.rbenv/versions/2.1.0/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/Naomi/.rbenv/versions/2.1.0/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}/lib

extconf failed, exit code 1

Gem files will remain installed in /Users/Naomi/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/pg-0.17.1 for inspection. Results logged to /Users/Naomi/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/pg-0.17.1/gem_make.out

Pretty please help. And yes, people have suggested other clouds, servers, services, etc. However, I have $0. Everyone else in the world seems to be able to push to Heroku. Please help me configure pg so I can push to Heroku. Thanks!