undefined method `last' for {}:Hash on rake db:migrate

4 views
Skip to first unread message

Ruby Freak

unread,
Jan 10, 2008, 1:05:18 AM1/10/08
to substruct
I have tried everything I can think of to make this work for 3 days.

Here is what I did:
rails _1.2.5_ little_ones_bend
svn export [substruct svn address] vendor/plugins --username substruct
--password substruct
svn export http://dev.rubyonrails.org/svn/rails/tags/rel_1-2-5 vendor/
rails
followed instructions from http://dev.subimage.com/projects/substruct/wiki/InstallingSubstruct
ruby script/generate plugin_migration
rake db:migrate

As near as I can tell, the engine plugin is sending a hash to the
function named "redefine_task"
which calls "resolve_args" and dies because Hash has no .last method
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1653:in
`resolve_args'

here it is. error on line 1653
def resolve_args(args)
task_name = args.shift
arg_names = args #.map { |a| a.to_sym }
needs = []
if task_name.is_a?(Hash)
hash = task_name
task_name = hash.keys[0]
needs = hash[task_name]
end
1653 if arg_names.last.is_a?(Hash)
hash = arg_names.pop
needs = hash[:needs]
fail "Unrecognized keys in task hash: #{hash.keys.inspect}" if
hash.size > 1
end
needs = [needs] unless needs.respond_to?(:to_ary)
[task_name, arg_names, needs]
end


Here is the engine code that is calling redefine_task
Rake::Task.redefine_task(plugin => :environment) do
plugin_base = RAILS_ROOT + "/vendor/plugins/#{plugin}"
options = []
files = Rake::FileList.new
options << "-o doc/plugins/#{plugin}"
options << "--title '#{plugin.titlecase} Plugin
Documentation'"
options << '--line-numbers' << '--inline-source'
options << '-T html'



C:\rails_projects\little_ones_bend>rake db:migrate --trace
(in C:/rails_projects/little_ones_bend)
rake aborted!
undefined method `last' for {}:Hash
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1653:in
`resolve_args'
C:/rails_projects/little_ones_bend/config/../vendor/plugins/engines/
tasks/engine
s.rake:9:in `redefine_task'
C:/rails_projects/little_ones_bend/config/../vendor/plugins/engines/
tasks/engine
s.rake:24:in `redefine_task'
C:/rails_projects/little_ones_bend/config/../vendor/plugins/engines/
tasks/engine
s.rake:63
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `send'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each'
C:/rails_projects/little_ones_bend/config/../vendor/plugins/engines/
tasks/engine
s.rake:61
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1737:in
`in_namespace'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:821:in
`namespace'
C:/rails_projects/little_ones_bend/config/../vendor/plugins/engines/
tasks/engine
s.rake:58
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1737:in
`in_namespace'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:821:in
`namespace'
C:/rails_projects/little_ones_bend/config/../vendor/plugins/engines/
tasks/engine
s.rake:54
C:/rails_projects/little_ones_bend/vendor/rails/railties/lib/tasks/
rails.rb:8:in
`load'
C:/rails_projects/little_ones_bend/vendor/rails/railties/lib/tasks/
rails.rb:8
C:/rails_projects/little_ones_bend/vendor/rails/railties/lib/tasks/
rails.rb:8:in
`each'
C:/rails_projects/little_ones_bend/vendor/rails/railties/lib/tasks/
rails.rb:8
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_re
quire'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
C:/rails_projects/little_ones_bend/rakefile:10
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2149:in `load'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2149:in
`raw_load_rakefile
'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1897:in
`load_rakefile'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
`standard_exceptio
n_handling'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1896:in
`load_rakefile'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1880:in `run'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
`standard_exceptio
n_handling'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
C:/ruby/bin/rake:19:in `load'
C:/ruby/bin/rake:19

Oliver Barnes

unread,
Jan 10, 2008, 7:22:43 AM1/10/08
to subs...@googlegroups.com
I ran into the same issue. I didn't find a fix yet, but managed rake
working again after commenting out the tasks at
vendor/plugins/engines/tasks/engines.rake

2008/1/10, Ruby Freak <twsca...@gmail.com>:

Oliver Barnes

unread,
Jan 10, 2008, 7:23:57 AM1/10/08
to subs...@googlegroups.com
...managed TO GET rake working...

2008/1/10, Oliver Barnes <ol1b...@gmail.com>:

Ruby Freak

unread,
Jan 10, 2008, 9:03:52 AM1/10/08
to substruct
Yes, I got migrations to work by commenting the following code it
engines.rake
Not sure what the effect is

# this is just a modification of the original task in railties/lib/
tasks/documentation.rake,
# because the default task doesn't support subdirectories like
<plugin>/app or
# <plugin>/component. These tasks now include every file under a
plugin's code paths (see
# Plugin#code_paths).
# namespace :doc do

# plugins = FileList['vendor/plugins/**'].collect { |plugin|
File.basename(plugin) }

# namespace :plugins do

# Define doc tasks for each plugin
# plugins.each do |plugin|
# desc "Create plugin documentation for '#{plugin}'"
# Rake::Task.redefine_task(plugin => :environment) do
# plugin_base = RAILS_ROOT + "/vendor/plugins/#{plugin}"
# options = []
# files = Rake::FileList.new
# options << "-o doc/plugins/#{plugin}"
# options << "--title '#{plugin.titlecase} Plugin
Documentation'"
# options << '--line-numbers' << '--inline-source'
# options << '-T html'

#Include every file in the plugin's code_paths (see
Plugin#code_paths)
# files.include("#{plugin_base}/
{#{Rails.plugins[plugin].code_paths.join(",")}}/**/*.rb")
# if File.exists?("#{plugin_base}/README")
# files.include("#{plugin_base}/README")
# options << "--main '#{plugin_base}/README'"
# end
# files.include("#{plugin_base}/CHANGELOG") if File.exists?
("#{plugin_base}/CHANGELOG")

# if files.empty?
# puts "No source files found in #{plugin_base}. No
documentation will be generated."
# else
# options << files.to_s
# sh %(rdoc #{options * ' '})
# end
# end
#end
# end
# end

Thanks Oliver.

On Jan 10, 4:23 am, "Oliver Barnes" <ol1bar...@gmail.com> wrote:
> ...managed TO GET rake working...
>
> 2008/1/10, Oliver Barnes <ol1bar...@gmail.com>:
>
> > I ran into the same issue. I didn't find a fix yet, but managed rake
> > working again after commenting out the tasks at
> > vendor/plugins/engines/tasks/engines.rake
>
> > 2008/1/10, Ruby Freak <twscann...@gmail.com>:
>
> > > I have tried everything I can think of to make this work for 3 days.
>
> > > Here is what I did:
> > > rails _1.2.5_ little_ones_bend
> > > svn export [substruct svn address] vendor/plugins --username substruct
> > > --password substruct
> > > svn exporthttp://dev.rubyonrails.org/svn/rails/tags/rel_1-2-5vendor/
> > > rails
> > > followed instructions fromhttp://dev.subimage.com/projects/substruct/wiki/InstallingSubstruct

alloca_

unread,
Jan 10, 2008, 12:23:18 PM1/10/08
to substruct
This is a problem with recent versions of rake, if you use an older
version it still works, Im' using rake 0.7.3.
Reply all
Reply to author
Forward
0 new messages