Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: Compiled Slug Size is too large

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.

like image 633
scientiffic Avatar asked May 12 '15 19:05

scientiffic


People also ask

What is slug size?

A slug is essentially the compressed copy of your application comprising of your git repo along with packages that are installed at deploy time like gems, node_modules, etc. The maximum allowed slug size (after compression) is 500MB. Applications using multiple buildpacks especially can strain this limit.

How do I save in Heroku?

When a new Dyno is started, the Dyno will have the same filesystem that was compiled when your application was built during deployment. To permanently store files, you will need to use a mass storage system such as AWS S3. AWS has a great public API, and plugins for all major languages and Frameworks.


2 Answers

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
like image 118
Lukas Eklund Avatar answered Oct 31 '22 00:10

Lukas Eklund


this worked for me

$ heroku repo:gc -a appname

Will run git gc --aggressive on your repo.

$ heroku repo:purge_cache -a appname

Then I mannually pushed code to heroku

$ git push heroku-prod master
like image 34
illusionist Avatar answered Oct 30 '22 22:10

illusionist