9

I have everything installed. But when I run "rake db:create", I get the following:

Ken-Vogts-MacBook:sixmonths ken$ rake db:create
(in /Users/ken/sixmonths)
rake aborted!
no such file to load -- pg

Here is my database.yml:

development:
  adapter: postgresql
  encoding: unicode
  database: sixmonths_development
  pool: 5
  username: postgres
  password: xxxxxxxx

test:
    adapter: postgresql
    encoding: unicode
    database: sixmonths_test
    pool: 5
    username: sixmonths
    password: xxxxxxxx

production:
    adapter: postgresql
    encoding: unicode
    database: sixmonths_production
    pool: 5
    username: sixmonths
    password: xxxxxxxx

I can see pg is installed when I run: gem list

I tried replacing "postgresql" with "pg" per another post on stackoverflow, but it resulted in this:

Ken-Vogts-MacBook:sixmonths ken$ rake db:create
(in /Users/ken/sixmonths)

Seems cool, right?

Nope. Next, I try "rake db:schema:dump" and I get this:

Ken-Vogts-MacBook:sixmonths ken$ rake db:schema:dump
(in /Users/ken/sixmonths)
rake aborted!
Please install the pg adapter: `gem install activerecord-pg-adapter` (no such file to load -- active_record/connection_adapters/pg_adapter)

Of course there is no "activerecord-pg-adapter". What do I have to do to make this work?

Gemfile Contents:

source 'rubygems.org'
gem 'rails', '3.0.0' 
# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 
gem 'sqlite3-ruby', :require => 'sqlite3' 
# gem 'unicorn' 
# gem 'capistrano'
# gem 'ruby-debug'
# Bundle the extra gems: 
# gem 'bj' 
# gem 'nokogiri' 
# gem 'sqlite3-ruby', :require => 'sqlite3' 
# gem 'aws-s3', :require => 'aws/s3' 
# Bundle gems for the local environment. Make sure to 
# put test-only gems in this group so their generators 
# and rake tasks are available in development mode: 
# group :development, :test do 
  # gem 'webrat' 
# end
3
  • Does your Gemfile have gem 'pg' in it? Commented Mar 2, 2011 at 5:04
  • @dmarkow Here is my Gemfile: (see next comment) Commented Mar 2, 2011 at 18:19
  • source 'rubygems.org' gem 'rails', '3.0.0' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3-ruby', :require => 'sqlite3' # gem 'unicorn' # gem 'capistrano' # gem 'ruby-debug' # Bundle the extra gems: # gem 'bj' # gem 'nokogiri' # gem 'sqlite3-ruby', :require => 'sqlite3' # gem 'aws-s3', :require => 'aws/s3' # Bundle gems for the local environment. Make sure to # put test-only gems in this group so their generators # and rake tasks are available in development mode: # group :development, :test do # gem 'webrat' # end Commented Mar 2, 2011 at 18:22

2 Answers 2

12

Rails 3 will only let you access the gems you specify in your Gemfile, so even if you have it installed in your system-wide gems by doing a gem install pg, it won't be able to find it.

Add gem 'pg' to your Gemfile, run bundle install, and you should be good to go.

Sign up to request clarification or add additional context in comments.

2 Comments

I added gem 'pg' per your instructions. The adapter that works is "postgresql", not "pg" for those who read about my flailing attempts above. Now on to learning about postgresql (I am a mysql guy).
Yes, even though the gem is pg, you still use postgresql in your database.yml
0

I tried many things that I saw as solutions elsewhere, but the only thing that worked for me was replacing

gem 'sqlite3'

with

gem 'pg'

in Gemfile. My database.yml looks the same as yours.

Now both >rake db:create and >rake db:migrate work.

This is on OSX Snow Lepoard, Rails 3.0.7, Postgres 9.0.

And the output from:

gem list --local

is

pg (0.11.0)
polyglot (0.3.1)
postgres-pr (0.6.3)
rack (1.2.2, 1.0.1)
rack-mount (0.7.2, 0.7.1, 0.6.14)
rack-test (0.6.0, 0.5.7)
rails (3.0.7, 3.0.5, 2.3.5, 2.2.2, 1.2.6)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.