Can't rake build. Stack trace points to ruby_executable_hooks - ruby-on-rails

I'm not sure when this happened, but I've gotten my environment into a state where I can't rake build. I looked at the stack trace, but nothing in it is helpful for me.
$ bundle exec rake build --trace
rake aborted!
Don't know how to build task 'build' (see --tasks)
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/task_manager.rb:71:in `[]'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:149:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

Related

'rake db:migrate:up VERSION=' aborts

I created a migration. I am trying to run it by:
rake db:migrate:up VERSION=
It raises the following error:
D, [2018-06-03T13:20:41.295098 #2257] DEBUG -- : ** [Raven] Sending event 2a32cb0c249acd2efde26ce6453a2d77 to Sentry
D, [2018-06-03T13:20:41.343397 #2257] DEBUG -- : ** [Raven] Raven HTTP Transport connecting to https://app.getsentry.com
rake aborted!
NoMethodError: undefined method `last_comment' for #<Rake::Application:0x007fb71d8a76a0>
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/rake_task.rb:101:in `define'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/rake_task.rb:78:in `initialize'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-rails-3.0.2/lib/rspec/rails/tasks/rspec.rake:11:in `new'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-rails-3.0.2/lib/rspec/rails/tasks/rspec.rake:11:in `<top (required)>'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-rails-3.0.2/lib/rspec-rails.rb:13:in `block in <class:Railtie>'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie.rb:237:in `instance_exec'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie.rb:237:in `block in run_tasks_blocks'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie.rb:245:in `each'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie.rb:245:in `each_registered_block'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie.rb:237:in `run_tasks_blocks'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:437:in `block in run_tasks_blocks'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine/railties.rb:13:in `each'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine/railties.rb:13:in `each'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:437:in `run_tasks_blocks'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:453:in `load_tasks'
/Rakefile:6:in `<top (required)>'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:104:in `block in load_rakefile'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:103:in `load_rakefile'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:82:in `block in run'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/lib/rake/application.rb:80:in `run'
/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/.rbenv/versions/2.1.2/bin/rake:23:in `load'
/.rbenv/versions/2.1.2/bin/rake:23:in `<main>'
How can I deal with it?
Specify version when migrating. This is good is you want to migrate only specific version of your migration. If you want to migrate all pending migration you can just say rake db:migrate.
Example:
rake db:migrate:up VERSION=20120820165642
I had to run the command against local rails
rake db:migrate:up VERSION=20120820165642 RAILS_ENV=test
works for me

Rake tasks keep failing

I'm trying to set up my development environment to work with an existing project that's using Mongoid. I've run bundle install and that worked fine, but I'm now trying to set up the database, and I'm running rake db:setup
Here's the output:
[1] $ rake db:setup --trace ✘
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/bundler/gems/cantango-36e3ce152717/lib/cantango/configuration/registry.rb:31:in `register'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/bundler/gems/cantango-36e3ce152717/lib/cantango/configuration/candidate_registry.rb:10:in `register'
/home/chintanparikh/Documents/Work/project_name/config/initializers/cantango.rb:8:in `block in <top (required)>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/bundler/gems/cantango-36e3ce152717/lib/cantango.rb:23:in `configure'
/home/chintanparikh/Documents/Work/project_name/config/initializers/cantango.rb:2:in `<top (required)>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:555:in `each'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:555:in `block in <class:Engine>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/chintanparikh/Documents/Work/project_name/config/environment.rb:5:in `<top (required)>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/application.rb:193:in `block (2 levels) in initialize_tasks'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:227:in `call'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:227:in `block in execute'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:222:in `each'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:222:in `execute'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/chintanparikh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:185:in `each'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:185:in `invoke_prerequisites'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/home/chintanparikh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:185:in `each'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:185:in `invoke_prerequisites'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/home/chintanparikh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/task.rb:152:in `invoke'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:141:in `invoke_task'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:99:in `each'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:99:in `block in top_level'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:108:in `run_with_threads'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:93:in `top_level'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:71:in `block in run'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:158:in `standard_exception_handling'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/lib/rake/application.rb:68:in `run'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/gems/rake-10.0.1/bin/rake:37:in `<top (required)>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/bin/rake:19:in `load'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/bin/rake:19:in `<main>'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/bin/ruby_noexec_wrapper:14:in `eval'
/home/chintanparikh/.rvm/gems/ruby-1.9.3-p0#global/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:setup => db:create => environment
Does anyone know how to fix this? It looks like it's failing on the create step.
Cheers.
MongoDB is a schema-less database. You don't need to use any of the rake db:{} functions with it. The only thing you need to do to have mongodb up and running is to install it and then to start the server. You can find more information on installing MongoDB here

Rake Task to Restart Heroku Server

I'm trying to create a rake task that restarts my heroku servier. I've found this post, which has helped immensely: http://railspikes.com/2010/2/13/rake-task-for-deploying-to-heroku.
I've cobbled together this rake task, but it's giving me an error. The rake abouts and I get the message:
uninitialized constant Heroku::Command::BaseWithApp.
This is my method.
desc 'restarts the server'
task restart_server: :environment do
require 'heroku'
require 'heroku/command'
user, pass = File.read(File.expand_path("~/.heroku/credentials.txt")).split("\n")
heroku = Heroku::Client.new(user, pass)
cmd = Heroku::Command::BaseWithApp.new([])
remotes = cmd.git_remotes(File.dirname(__FILE__) + "/../..")
remote, app = remotes.detect {|key, value| value == (ENV['APP'])}# || cmd.app)}
if remote.nil?
raise "Could not find a git remote for the '#{ENV['APP']}' app"
end
heroku.restart(ENV['APP'])
end
I'm not sure why it's rejecting Heroku::Command. The app is already live on Heroku, so I know it's Heroku compliant.
Any advice?
EDIT: Here's my stack trace.
** Invoke restart_server (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute restart_server
rake aborted!
uninitialized constant Heroku::Command::BaseWithApp
/Users/bendowney/Sites/ProblemChildApp/lib/tasks/scheduler.rake:51:in `block in <top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bendowney/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#ProblemChildApp/bin/ruby_noexec_wrapper:14:in `eval'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#ProblemChildApp/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => restart_server

cannot destroy a database using rake

I am new to rails and while practising the tutorials I got the following error. Any ideas..
$ rake destroy scaffold Microposts --trace
rake aborted!
Don't know how to build task 'destroy'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:115:in `invoke_task'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/home/keval/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
trey rails destroy scaffold Microposts

YAML DB won't run due to evaluating nil.each

So this problem is occurring for me on both RHEL5 and OSX Lion. Both environments are running 1.9.2-p290 ruby installed with RVM.
When I run the following command I get the following problem:
[master][~/Sites/boss-mocha] bundle exec rake db:data:load --trace
** Invoke db:data:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:data:load
rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:85:in `load_records'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:74:in `load_table'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:63:in `block (2 levels) in load_documents'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:61:in `each'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:61:in `block in load_documents'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/deprecated.rb:30:in `each'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/deprecated.rb:30:in `load_documents'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:60:in `load_documents'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:57:in `block in load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:56:in `load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:31:in `load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/tasks/yaml_db_tasks.rake:35:in `block (3 levels) in <top (required)>'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => db:data:load
The YAML being produced by rake db:data:dump appears mal-formed, with spurious "---"s between the "records" list and the actual records.
Removing the inappropriate "---" allows the data to load. I haven't created a pull request for the fix yet, but after tracking it down I noticed someone else reported it as an issue on github:
https://github.com/ludicast/yaml_db/issues/17
In addition, changing the YAML engine as in the link below produces correct output, eliminating the need for editing the file manually (or fixing yaml_db).
rails error, couldn't parse YAML

Resources