I have this in lib/tasks/foo.rake:
Rake::Task["assets:precompile"].enhance do
print ">>>>>>>> hello from precompile"
end
Rake::Task["assets:precompile:nondigest"].enhance do
print ">>>>>>>> hello from precompile:nondigest"
end
When I run rake assets:precompile locally, both messages are printed.
When I push to heroku, only the nondigest message is printed. However, according to the buildpack, the push is executing the exact same command as I am locally.
Why does the enhancement to the base assets:precompile case not work on heroku but does work locally?
i’ve been looking into this issue and I found out that the behavior of the
assets:precompiledepending on ifRAILS_ENVandRAILS_GROUPSare both set or not take a look at this locally.The problem comes from https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/sprockets/assets.rake in
invoke_or_reboot_rake_taskmethod if you replace theRake::Task[task].invokeline withruby_rake_task taskthen it works like you would expect it to. I’ve been poking around on exactly why this is, and haven’t found the reason.Since both variables are set in the Heroku build pack, you could create a custom build pack without setting both GROUP and ENV settings, though I think that is overkill. In this scenario you should be able to enhance
assets:precompile:primaryorassets:precompile:alland achieve an outcome similar to your desired intent.