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

Cannot install 'pg' (needed for Heroku)

Im trying to push my repository onto heroku and have been running into back to back issues. After finally being able to get past the permission denied key (heroku keys:add was not working) I still cant push into heroku.

I keep getting the following issue:

An error occurred while installing sqlite3 (1.3.8), and Bundler cannot continue.
       Make sure that `gem install sqlite3 -v '1.3.8'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !     
 !     Detected sqlite3 gem which is not supported on Heroku.
 !     https://devcenter.heroku.com/articles/sqlite3
 !

 !     Push rejected, failed to compile Ruby app

The first step mentioned in https://devcenter.heroku.com/articles/sqlite3 is to replace gem 'sqlite3' in my gemfile with gem 'pg'. However, I get the following error when I try to bundle:

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

    /Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/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/ureyes/.rvm/rubies/ruby-1.9.3-p484/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


Gem files will remain installed in /Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/pg-0.17.1 for inspection.
Results logged to /Users/ureyes/.rvm/gems/ruby-1.9.3-p484/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.

Please help!

9 Answers

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

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: your_app_name
  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

Include the following in your Gemfile:

group :development, :test do
    gem 'sqlite3'
end

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

ruby "2.1.0"

(or whichever version of ruby you're using)

Also, remember to delete the sqlite3 gem up near the top of your Gemfile.

Thanks Naomi for reaching out to help, but I can't quite understand what you want me to do. Can you include 3 backticks ( ``` ) before and after your code in order for it to appear formatted properly? thanks!

I followed all the steps, but this is what i get when I try to run rake db:create

Ulisess-MacBook-Air:treebook2 ureyes$ rake db:create
could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (fe80::1) and accepting
    TCP/IP connections on port 5432?
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:144:in `rescue in create_database'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:85:in `create_database'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `load'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"treebook", "host"=>"localhost"}
db/test.sqlite3 already exists
Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Try this:

env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config

(just copy that whole block and paste it into your terminal and hit enter)

Once that succeeds, run bundle to do the rest of your gems.

Have you updated your gemfile and database.yml files?

Thanks. Unfortunately that did not work. What worked for me was to install homebrew and run

$brew install postgresql

After that, the bundle was able to work. However, after doing that, I tried to update my database.yml file and get the following error when I run rake db:create:

could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:144:in `rescue in create_database'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:85:in `create_database'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `load'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"db/treebook_development", "pool"=>5, "timeout"=>5000}
could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:144:in `rescue in create_database'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:85:in `create_database'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/ureyes/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `load'
/Users/ureyes/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"db/treebook_test", "pool"=>5, "timeout"=>5000}

This is what my database.yml file looks like for reference:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: postgresql
  database: treebook_development
  pool: 5
  timeout: 5000

# 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: postgresql
  database: treebook_test
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: treebook_production
  pool: 5
  timeout: 5000

Thanks Naomi for reaching out to help, but I can't quite understand what you want me to do. Can you include 3 backticks ( ``` ) before and after your code in order for it to appear formatter properly? thanks!

Naomi Freeman
Naomi Freeman
Treehouse Guest Teacher

Sorry! No problem. I couldn't figure out how to make it do it on purpose. Now it's formatted.

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

This is because of how your postgres is configured.

Since you used homebrew and I have done it using that other piece of code, we will have different set-ups.

Stack overflow says this about your error: (it looks like you need to change where your localhost is defaulting to)

http://stackoverflow.com/questions/17648677/is-the-server-running-on-host-localhost-1-and-accepting-tcp-ip-connections


Other times I've gotten an error like that I accidentally had the rails server running in another terminal window.

Also, make sure you rake db:drop first, then rake db:create, rake db:migrate

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Ulises Reyes try doing the following:

In your Gemfile make sure that you move the sqlite3 gem to the development group and put pg in the production group. It should look like this:

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

Then do:

bundle install --without=production

That should get you running locally. Finally try doing:

git push heroku master

And that should get you deployed out to heroku.

Jared Galanis
Jared Galanis
8,382 Points

I too am having problems deploying to Heroku, although my errors seem to be occurring during the precompile. I've tried running ```RAILS_ENV=production bundle exec rake assets:precompile

which doesn't resolve the issue. I've also added the gem 'rails_12factor' to my production section of the gem file.  I also tried changing the production setting the database.yml file to postgresql, which also doesn't help.  I do have: 
```    config.assets.initialize_on_precompile = false

in my application.rb file. I've also followed Jason's instructions above to no avail. Many thanks in advance for any ideas that folks have. Here is the error I'm getting.

git push heroku master
Initializing repository, done.
Counting objects: 334, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (309/309), done.
Writing objects: 100% (334/334), 291.50 KiB | 0 bytes/s, done.
Total 334 (delta 134), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.5.2
       New app detected loading default bundler cache
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/..........
       Fetching additional metadata from https://rubygems.org/..
       Using i18n (0.6.9)
       Using multi_json (1.8.4)
       Using rake (10.1.1)
       Using minitest (4.7.5)
       Using atomic (1.1.14)
       Using tzinfo (0.3.38)
       Using builder (3.1.4)
       Using erubis (2.7.0)
       Using rack (1.5.2)
       Using mime-types (1.25.1)
       Using activerecord-deprecated_finders (1.0.3)
       Installing polyglot (0.3.3)
       Using execjs (2.0.2)
       Using thor (0.18.1)
       Installing coffee-script-source (1.6.3)
       Using hike (1.2.3)
       Using json (1.8.1)
       Using pg (0.17.1)
       Using bundler (1.5.2)
       Using tilt (1.4.1)
       Installing arel (4.0.1)
       Using thread_safe (0.1.3)
       Using rack-test (0.6.2)
       Installing orm_adapter (0.5.0)
       Using treetop (1.4.15)
       Using coffee-script (2.2.0)
       Using rdoc (3.12.2)
       Using uglifier (2.4.0)
       Installing warden (1.2.3)
       Installing bcrypt-ruby (3.1.2)
       Using mail (2.5.4)
       Installing sass (3.2.13)
       Installing activesupport (4.0.2)
       Installing sprockets (2.10.1)
       Using jbuilder (1.5.3)
       Installing sdoc (0.3.20)
       Installing activemodel (4.0.2)
       Installing actionpack (4.0.2)
       Using sprockets-rails (2.0.1)
       Installing actionmailer (4.0.2)
       Installing simple_form (3.0.1)
       Installing railties (4.0.2)
       Using coffee-rails (4.0.1)
       Using sass-rails (4.0.1)
       Installing activerecord (4.0.2)
       Installing jquery-rails (3.0.4)
       Installing turbolinks (2.1.0)
       Installing devise (3.2.3)
       Installing rails (4.0.2)
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (12.08s)
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       I, [2014-03-11T05:28:49.499979 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/glyphicons-halflings-regular-9424bcf8f49d772c152e0b760b39b8f9.eot
       I, [2014-03-11T05:28:49.502125 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/glyphicons-halflings-regular-ab814146cdfc4d37cc90765f7bf86107.svg
       I, [2014-03-11T05:28:49.504174 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/glyphicons-halflings-regular-7531c2bd6e03c07cc2d83fa38e1e2218.ttf
       I, [2014-03-11T05:28:49.540859 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/glyphicons-halflings-regular-fcc658a3dec1be1cb0a9bb81f4c7c6de.woff
       I, [2014-03-11T05:28:49.542687 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/glyphicons-halflings-white-ed38e147e3f6e976c0a7ad59e4d628f3.png
       I, [2014-03-11T05:28:49.544380 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/glyphicons-halflings-7eb193615ec1fe31f5bc9026084e1032.png
       I, [2014-03-11T05:28:55.660162 #812]  INFO -- : Writing /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/public/assets/application-8f3ce83e8ed44181a2ca4866e3268a72.js
       rake aborted!
       Invalid CSS after "...":3,"sources":[": expected "|", was ""less/theme.les..."
       (in /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/app/assets/stylesheets/application.css)
       (sass):367
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:1147:in `expected'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:1085:in `expected'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:1080:in `tok!'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:785:in `attrib_name!'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:753:in `attrib'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:672:in `simple_selector_sequence'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:646:in `_selector'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:619:in `selector'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:603:in `selector_sequence'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:528:in `ruleset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:591:in `block in declaration_or_ruleset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:1123:in `call'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:1123:in `rethrow'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:592:in `declaration_or_ruleset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:554:in `block_child'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:543:in `block_contents'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:535:in `block'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:529:in `ruleset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:553:in `block_child'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:546:in `block_contents'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:82:in `stylesheet'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/scss/parser.rb:27:in `parse'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/engine.rb:342:in `_to_tree'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/engine.rb:315:in `_render'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sass-3.2.13/lib/sass/engine.rb:262:in `render'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/sass_compressor.rb:24:in `evaluate'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/context.rb:197:in `block in evaluate'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/context.rb:194:in `each'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/context.rb:194:in `evaluate'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/bundled_asset.rb:25:in `initialize'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/base.rb:377:in `new'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/base.rb:377:in `build_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/index.rb:94:in `block in build_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/caching.rb:58:in `cache_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/index.rb:93:in `build_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/base.rb:287:in `find_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/index.rb:61:in `find_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/manifest.rb:211:in `block in find_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/manifest.rb:257:in `benchmark'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/manifest.rb:210:in `find_asset'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/manifest.rb:119:in `block in compile'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/manifest.rb:118:in `each'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/sprockets/manifest.rb:118:in `compile'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-2.10.1/lib/rake/sprocketstask.rb:146:in `with_logger'
       /tmp/build_45fc5abd-fc60-4963-b8fa-d1d5cbdefe61/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define'
       Tasks: TOP => assets:precompile
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby app
Jared Galanis
Jared Galanis
8,382 Points

Update on my issue. I was able to get the assets compiled locally and then deployed to Heroku using Jason's suggestion here, https://teamtreehouse.com/forum/precompiling-assets-failed-enabling-runtime, to check out Heroku's discussion on the rails asset pipeline. However, problems are still occurring now that app is deployed, so I suspect I just hid the problem. I'm now getting the following from Heroku when I visit the url of the app: "Application Error. An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details." Any further thoughts would still be greatly appreciated.

Jared Galanis
Jared Galanis
8,382 Points

this is error in the Heroku logs

300 <158>1 2014-03-12T01:39:58.343240+00:00 d.4d13135b-5119-4677-b994-8558edebfc79 heroku router - - at=error code=H10 desc="App crashed" method=GET path=/ host=peaceful-gorge-8451.herokuapp.com request_id=e537126d-480a-4d9b-b2b7-72cfdc882838 fwd="108.40.38.75" dyno= connect= service= status=503 bytes=
Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Jared Galanis try adding the following to your Gemfile:

gem 'rails_12factor', group: :production

That may fix the error. Read more about it here.

Ben Bowden
Ben Bowden
7,841 Points

Adding "gem 'rails_12factor', group: :production" helped me. Thanks so much Jason!