Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

test tasks fail when db/schema.rb doesn't exist

#3012

Check this:

$ rails zomg-no-db
$ cd zomg-no-db
$ rake --trace test
(in /Users/nichoj/code/experimental/zomg-no-db)
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment 
** Execute db:schema:load
rake aborted!
no such file to load -- /Users/nichoj/code/experimental/zomg-no-db/db/schema.rb
/gentoo/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/gentoo/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:145:in `load'
/gentoo/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/gentoo/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:145:in `load'
/gentoo/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/databases.rake:259
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/gentoo/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/databases.rake:304
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/gentoo/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/databases.rake:378
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/gentoo/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/testing.rake:45
/gentoo/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/testing.rake:43:in `collect'
/gentoo/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/testing.rake:43
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/gentoo/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/gentoo/usr/bin/rake18:19:in `load'
/gentoo/usr/bin/rake18:19

You can get around this by running rake db:create db:migrate, but a more friendly error message should be possible.

Reported by Josh Nichols · August 8th, 2009 @ 09:56 PM

State: committed
Milestone: 2.3.4
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Rizwan Reza
    Rizwan Reza
    • Tag set to bugmash, error, verified

    verified

    +1 Agreed. That is sure to scare a beginner. :)

    August 8th, 2009 @ 10:00 PM

  2. Josh Nichols
    Josh Nichols

    Chrome has failed me for the last time for attaching a patch.

    No tests, because there's no previous tests for rake stuff.

    August 8th, 2009 @ 10:46 PM

  3. Dan Croak
    Dan Croak

    +1 verified patch applies cleanly. Looks like the right error message now.

    August 8th, 2009 @ 10:49 PM

  4. John Trupiano
    John Trupiano

    +1 verified patch applies cleanly, addresses something I think should be fixed.

    It's worth pointing out that rails can be used without a database. Would it make sense to change the error message from:

      db/schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again.
    

    to

      db/schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again.  If you do not intend to use a database, you should instead alter config/environment.rb to remove active_record: config.frameworks -= [ :active_record ]
    

    I've attached a revised patch for consideration.

    August 9th, 2009 @ 04:08 PM

  5. Rizwan Reza
    Rizwan Reza

    verified

    +1 The patch applies cleanly to master and 2-3-stable.

    August 9th, 2009 @ 04:14 PM

  6. Nikolay Petrachkov
    Nikolay Petrachkov
    • Assigned user set to Pratik
    • Tag changed from bugmash, error, verified to bugmash, error, patch, verified

    +1 Patch works for 2-3.

    August 9th, 2009 @ 04:21 PM

  7. Elad Meidar
    Elad Meidar

    +1 on idea and message, verified and applies cleanly on 2-3-stable and master

    sidenote: there should be a test suit for the basic included rake tasks, there are tests.

    August 9th, 2009 @ 05:22 PM

  8. Josh Nichols
    Josh Nichols

    +1 on John's message tweaks. I had thought to include a message to that effect, but figured it'd be a little too verbose. Looks fine though.

    August 9th, 2009 @ 05:34 PM

  9. David Trasbo
    David Trasbo

    +1

    Applies cleanly to edge Rails. But the patch needs tests.

    August 9th, 2009 @ 07:34 PM

  10. Josh Nichols
    Josh Nichols

    As I said before, there aren't any tests for ANY of the rake tasks, so starting to do that just for this one patch seems a little overwhelming.

    August 9th, 2009 @ 08:14 PM

  11. Derander
    Derander
    • Assigned user cleared.

    +1

    I frequently write rails apps with no database.

    Patch applied cleanly to 2-3-stable and master.

    August 9th, 2009 @ 08:22 PM

  12. Derander
    Derander
    • Assigned user set to Pratik

    Oops, apparently I cleared the assigned user. That wasn't intentional.. undoing that.

    August 9th, 2009 @ 08:22 PM

  13. Rebecca Frankel
    Rebecca Frankel

    +1 Yes, I really want this fix. I want to be reminded what to do rather than get a long stack trace that is always the same. Could there be analogous fixes for the perennial stack traces that result from not having some needed gem installed?

    patch applied to 2-3-stable. I ran the tests too, not that it makes a difference for a patch without tests.

    August 10th, 2009 @ 03:30 AM

  14. Hugo Peixoto
  15. Repository
    Repository
    • State changed from new to committed

    (from [84d24cdae8269a161d36e00009c043bbd102cbbd]) Only load db/schema.rb if it exists; otherwise, display a message to run db:migrate or remove active_record in environment.rb.

    [#3012 test tasks fail when db/schema.rb doesn't exist state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/84d24cdae8269a161d36e00009c043...

    August 10th, 2009 @ 04:19 AM

  16. Repository
    Repository

    (from [ebb6606a4d09ca362a0c56a458444a8dd551c495]) Only load db/schema.rb if it exists; otherwise, display a message to run db:migrate or remove active_record in environment.rb.

    [#3012 test tasks fail when db/schema.rb doesn't exist state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/ebb6606a4d09ca362a0c56a458444a...

    August 10th, 2009 @ 04:19 AM

  17. Jeremy Kemper
    Jeremy Kemper
    • Tag changed from bugmash, error, patch, verified to error, patch, verified
    • Milestone set to 2.3.4

    August 10th, 2009 @ 04:20 AM