Timothy Frisch
Timothy Frisch

Reputation: 2809

Heroku App trouble with pg in Gemfile

I have a Heroku app/RoR server set. When trying to run the command

bundle exec rake db:create db:migrate

I get a LoadError: cannot load such file -- 2.1/pg_ext?

I have this in my gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use postgresql as the database for Active Record
gem 'pg'
gem 'rails_12factor', group: :production
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# 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', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

gem 'puma'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

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

Not sure where I am going wrong...

I think I go wrong in that I am not setting up the SET DATABASE_URL=postgres:///$(whoami) correctly, what is the format for this command?

I get a different error after trying some things now:

rake aborted! PG::ConnectionBad: fe_sendauth: no password provided

Where do I have to provide this password?

Upvotes: 0

Views: 162

Answers (2)

Eugene Auduchinok
Eugene Auduchinok

Reputation: 196

I use PostgreSQL at Heroku and SQLite for local development. If you rely on some Postgres specific features then it's probably not your case. Otherwise it can be good enough.

Here's a part from my Gemfile:

# Use sqlite3 as the database for Active Record
gem 'sqlite3', group: :development

# Deploy on Heroku
gem 'pg', group: :production
gem 'rails_12factor', group: :production

Upvotes: 1

Elvn
Elvn

Reputation: 3057

You have this listed as the command you ran that generated the error. This is not a valid command line:

bundle exec rake db:create db:migrate

These are 2 discrete actions. To create the database, first time, start with:

bundle exec rake db:create

On subsequent updates to the database use:

bundle exec rake db:migrate

Upvotes: 0

Related Questions