我已经在 Heroku 上运行了一段时间的应用程序,并且在最近的部署中看到了 Heroku gem 已被弃用以支持 Heroku Toolbelt 的消息。使用工具带,我所有的 Heroku 命令都可以在命令行中正常工作,但在 Rake 任务(我已经为部署设置)中,我收到以下错误:
$ rake deploy:staging
Everything up-to-date
/Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/gems/bundler-1.2.0/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': heroku is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/bin/heroku:18:in `<main>'
from /Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/bin/ruby_noexec_wrapper:14:in `<main>'
/Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/gems/bundler-1.2.0/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': heroku is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/bin/heroku:18:in `<main>'
from /Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/aramisbear/.rvm/gems/ruby-1.9.3-p194@myapp/bin/ruby_noexec_wrapper:14:in `<main>'
显示的错误来自此部署 rake 任务:
namespace :deploy do
desc "deploys to Production after uploading assets to S3"
task :production do
puts `git push heroku master`
puts `heroku run rake db:migrate --app myapp`
puts `heroku restart --app myapp`
end
desc "deploys to Staging after uploading assets to S3"
task :staging do
puts `git push staging staging:master`
puts `heroku run rake db:migrate --app myapp-staging`
puts `heroku restart --app myapp-staging`
end
end
每个任务中的两个heroku 命令就是问题所在。如果我从命令行执行它们,它们就可以正常工作。我怀疑这很重要,但我也在用 RVM 运行 OSX。
知道如何解决这个问题吗?我意识到这不是什么大不了的事,因为我可以手动运行这些附加命令或给它们起别名,但我只想知道为什么首先会出现问题。