I've had an app running on Heroku for a while now and on a recent deployment saw the message that the Heroku gem was deprecated in favor of the Heroku Toolbelt. With the toolbelt, all of my Heroku commands work fine from the command line but within a Rake task (which I have setup for deployments) I get the following errors:
$ 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>'
The errors being shown are from this deployment rake task:
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
The two heroku commands in each task are where the problem comes from. If I execute them from the command line, they work just fine though. I doubt it matters but I'm running OSX with RVM as well.
Any idea how to fix this? I realize it's not a huge deal since I can just run those additional command manually or alias them, but I'd just like to know why there's a problem in the first place.
The gem's version of the heroku
command probably has a higher priority in your PATH than the system's.
I was able to reproduce this in a test project.
When I run which heroku
, I see that the shell's choice is /home/justinf/.rvm/gems/ruby-1.9.3-p286/bin/heroku
.
All it takes is a simple gem uninstall heroku
, answering yes to deleting the executable.
which heroku
now gives me /usr/bin/heroku
, and my test.rb now completes with no error instead of crashing out with a bundler exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With