Problem with rake: "development database not configured"

I am new to rails / terminal user and just did a clean install of Lion + Xcode + Rails. Unlike earlier (on Snow Leopard), now I get the rake db: migrate error message.

I cloned my code through git, which worked fine and created the database using the "createdb" command, but when I try to run "rake db: migrate" in the terminal, now it causes this error:

rake aborted! development database is not configured 

My config / database.yml file looks like the one shown below in the development section, which was the same as before, on Snow Leopard, where it worked fine, so I don’t know if the error I'm getting is related to Lion .

 development: adapter: postgresql database: my_db username: rasmus encoding: utf8 pool: 5 

Can someone please help?

+7
source share
7 answers

Solved!

My "gem install pg" was not running, so basically I lacked pg gem. After installing "gem install pg" in the terminal, everything works fine.

+1
source

I got the same error, and in my case it happened because database.yml was not indented correctly. All configuration parameters must be indented.

+18
source

Note. Be sure to follow the correct interval conventions. Database configuration is a space. Two spaces on an attribute work fine. In the following code, note that each attribute has two spaces. Do not use tabs. If you do not use spaces for attributes, the rake will not work and produces the same error.

 development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000 production: adapter: postgresql encoding: unicode database: db/production pool: 5 timeout: 5000 password: 
+4
source

You can also look for syntax errors in a file. This is the error that will appear if you have a syntax error in your config/database.yml file and you are trying to do something like starting a local web server or running rake db:migrate .

In my case, I accidentally deleted a comment from the line at the top of the file, and I saw this error, because the line without commenting made this an invalid yml file.

+2
source

Here's the PEBCAK answer for Googlers - check your Gemfile and make sure you specify your database adapter gem in the appropriate group in the Gemfile . I had something specific only for :production and :staging , and at some point you need to manually run gem install pg on my development machine after switching from mysql. This morning I emptied all the gems for the application and canceled them, and then I could not understand why the database would not connect. Moving the pg gem specification outside of any group and running bundle install resolved the issue.

+1
source

Note to other participants on this question page: make sure that you are running the rake db command correctly, for example:

rake db:migrate instead of rake db migrate

+1
source

What worked in my case, having tried everything above, when rake db: create failed, had to make sure that my Rakefile was configured correctly.

This completed the task:

 require "sinatra/activerecord/rake" require 'sinatra/asset_pipeline/task' namespace :db do task :load_config do require "./app" end end 
0
source

All Articles