2006.09.12

Ruby Rails

Railsでrake migrateできない現象にハマる

rake migrate

すると

rake aborted! can't convert Hash into String

とか言われてエラーが出る。rake migrate --traceしても訳の分からんエラーが... config/以下のファイルをいろいろ確認してみるものの、おかしなところはない。migrate以下のファイルをほかのRailsアプリで実行すると実行できるし...

で、いろいろさまよった挙げ句、エラーメッセージを見てみると...

/usr/local/ruby/lib/ruby/1.8/fileutils.rb:382:in `copy'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in `copy'
/path/to/railsapp/config/../config/routes.rb:47

これか!!
routes.rbでcopyを定義してたからか!!
ちなみにエラーメッセージはこんな感じ。

** Invoke migrate (first_time)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
can't convert Hash into String
/usr/local/ruby/lib/ruby/1.8/fileutils.rb:1392:in `directory?'
/usr/local/ruby/lib/ruby/1.8/fileutils.rb:1392:in `fu_each_src_dest0'
/usr/local/ruby/lib/ruby/1.8/fileutils.rb:1377:in `fu_each_src_dest'
/usr/local/ruby/lib/ruby/1.8/fileutils.rb:382:in `copy'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in `copy'
/path/to/railsapp/config/../config/routes.rb:47
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:625:in `draw'
/path/to/railsapp/config/../config/routes.rb:1
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'
/usr/local/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:608:in `reload'/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:239:in `initialize_routing'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:105:in `process'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:42:in `send'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/initializer.rb:42:in `run'
/path/to/railsapp/config/../config/environment.rb:13
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/tasks/misc.rake:3
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `call'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `each'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'
/usr/local/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:in `invoke_prerequisites'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `send'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in `invoke_prerequisites'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in `invoke'
/usr/local/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:in `invoke_prerequisites'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `send'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in `invoke_prerequisites'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in `invoke'
/usr/local/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `each'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
/usr/local/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/bin/rake:18:in `load'
/usr/bin/rake:18

ハマった。。
次からはちゃんとエラーメッセージよく読みます。