Recompile Heroku slug without push or config change
HerokuHeroku Problem Overview
I'm wondering if there is a way to force Heroku to recompile the slug without pushing new commits and/or updating the config variables.
Why would I want to do this?:
I am using the Cedar stack on Heroku for a Rails 3.2 app, and I am having problems with the rake assets:precompile
task failing (during compilation only --- later it works fine with a heroku run
). I highly suspect this is due to certain environment variables not being available during slug compilation time, and I think the heroku labs:enable user_env_compile
experimental feature will solve this.
However, with the user_env_compile
feature turned on, config changes do not trigger a recompilation of the slug, and my code hasn't changed, so I don't have any new commits to push.
Of course, I could push a "dummy" commit with a trivial change, which is probably the simplest answer --- but I'm wondering if there's a heroku command that will let me directly recompile the slug.
Thanks!
Heroku Solutions
Solution 1 - Heroku
The simplest workaround for now is to push an empty commit.
git commit --allow-empty -m "empty commit"
git push heroku master
Solution 2 - Heroku
Slug compilation is invoked with a git pre-recieve hook, so the only way to recompile is to push a new commit.
For completeness see this article on Heroku for the slug compiler. It discussed the use of the pre-recieve hook to invoke the slug compile process under the Compilation heading.
Solution 3 - Heroku
My general approach is to do:
git commit --amend -C HEAD
git push heroku master -f
Not sure I'd do this in production without being certain, as it does technically rewrite the last commit but it shouldn't cause any issues in theory. It's perfectly fine for when you are testing things in staging though.
As an added bonus since most people are problem using Vim to edit commit messages SHIFT-ZZ
will quickly save and exit the commit message for you without making any changes to it.
On a related note I'm mildly shocked Heroku still doesn't have this feature. I've often seen Heroku fail to deploy due to problems on their end.
Thanks to Michael Mior for the idea to use -C HEAD
to avoid opening up an editor.
Solution 4 - Heroku
Heroku have released a plugin that does this: https://github.com/heroku/heroku-repo
To install it:
$ heroku plugins:install heroku-repo
To force a rebuild:
$ heroku repo:purge_cache -a appname
$ heroku repo:reset -a appname
$ git push heroku
Solution 5 - Heroku
Update: heroku repo:rebuild has been removed.
Heroku has a Build API you can use, see: Building and Releasing Using the API
You can use the repo:rebuild command if the heroku-repo add-on.
heroku repo:rebuild -a appname
Solution 6 - Heroku
Looks like this is not yet available. However, a feature request has be opened on the heroku github repo
It also mentions "an alternate way to build that is not reliant on git push
"
Solution 7 - Heroku
There is a heroku plugin for this.
$ heroku plugins:install heroku-releases-retry
Installing plugin heroku-releases-retry... done
$ heroku releases:retry
Retrying v16 on ⬢ murmuring-lowlands-3398... done, v17
Solution 8 - Heroku
Heroku doesn't make it easy to find, but you can do it via the heroku dashboard if you navigate to your application. Select the "Deploy" tab and then scroll to the bottom of the page where you should see a section title "Manual deploy". In the input field enter your branch name and click the button "Deploy Branch"
Solution 9 - Heroku
Remove the branch, then re-push it. No need to use a plugin.
git push heroku :master
git push heroku master