I ran into this issue as well on a Rails 3.1 project. Dry YML (as recommended by many guides) that would have parsed perfectly before Rails 3.1 is no longer valid. Rails 3.1 switched yml parsers, for one, from 'syck' to 'psych'.
One of the consequences of this change -- an perhaps unknown changed to Rails 3.1 validation of database.yml -- is that the canonical DRY rails configuration that Eric M. was using triggers a 'Missing argument: database' error because :setup is being treated as a rails environment, and as such it fails validation because it does not contain a value for database. You can produce the same error by creating any arbitrary environment, leaving out the database field, and voila, problems running rake db:version or any database sensitive commands.
There are a number of possible workarounds (in order of my preference):
- Scrap the setup section and use your development environment as a
model for variable substitution, overriding the fields that are
different for test and production. With this setup, you have just
the environments rails expects, they all validate properly on load
with rake, and you still get a pretty dry setup.
https://gist.github.com/1242642
- Add a dummy database reference to the common the references an
existing database https://gist.github.com/1242623 that will get
overridden by any specific database: setting in your other profiles.
This will make "setup" a valid environment, though one that is next
explicitly used.
- Revert Rails 3.1 to the old YAML parsing engine. I have not tested this but several blog entries claim it works, though of course the unpleasant side effect is that you have forced Rails to use an older engine that was dropped probably for some good reasons. See for example Batcode Blog with Rails 3.1 error and workaround. The recommended step is to set
YAML::ENGINE.yamler = "syck"
at the top of your application.rb. You may need to require 'yaml'
first.
I am using the first solution in my Rails 3.1 application with no problems. Thanks Eric M. for raising this issue (not sure if you had a Rails 3.1 app or just some text gremlins since reversing the order worked for you but not for me).