Ruby-on-rails – Heroku: Compiled Slug Size is too large

herokuruby-on-rails

I've already spent half the day trying to debug a Heroku error where I can't push code to my staging server because of a slug compilation error:

Compiled slug size: 320.5MB is too large (max is 300MB).

I've moved all assets to AWS3 and created a .slugignore file with the following information:

*.psd
*.pdf
test
spec
features
doc
public

What other strategies can I use? The strangest thing is that, as far as I know, the code is the same as the production server, and I don't get any errors with pushing to the production server.

Best Solution

It's possible that before you added the .slugignore file you had some large files added the git repo and now they are in the slug cache or as git refs. The git-repo plugin has commands to fix these problems:

$ heroku repo:gc -a appname

Will run git gc --aggressive on your repo.

$ heroku repo:purge_cache -a appname

This will delete the build cache and then you probably should run to rebuild the application.

$ heroku repo:rebuild -a appname