0

我有以下任务:

task :migrate_test => :environment do
   puts 'Running database migrations ...'
   puts `heroku run rake db:migrate --app my-app`
end

当我heroku run rake db:migrate --app my-app在控制台中运行时,迁移成功进行。但是,当我运行时rake migrate_test,我收到以下错误:


Running database migrations ...
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/dependency.rb:52:in `initialize': Valid types are [:development, :runtime], not nil (ArgumentError)
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:371:in `new'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:371:in `search'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:361:in `gems_size'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:159:in `start'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:159:in `map'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:159:in `start'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:128:in `resolve'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:127:in `catch'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/resolver.rb:127:in `resolve'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/definition.rb:182:in `resolve'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/definition.rb:113:in `specs'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/definition.rb:162:in `specs_for'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/definition.rb:151:in `requested_specs'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/environment.rb:23:in `requested_specs'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:11:in `setup'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler.rb:116:in `setup'
    from /Users/Will/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/setup.rb:17

我相信这与在另一个找不到路径但无法找到解决方法的进程中运行任务有关。

4

2 回答 2

0

你的代码没有问题。在 GitHub 上查看此问题

只需更新 ruby​​gems 和 RVM。甚至更好:使用rbenv

于 2012-09-28T21:16:07.607 回答
0

解决方案是升级 Heroku 工具带。我仍然收到一个错误/Users/Will/.rvm/gems/ruby-1.9.3-p194@global/bin/rake: No such file or directory,但我猜工具带足够聪明,可以补偿。最新的工具带可以在这里找到:https ://toolbelt.heroku.com/

我还建议使用exec ...而不是puts ...在 rake 任务中,因为您将能够实时查看进度。

于 2012-11-24T19:32:40.363 回答