Heroku : Rails : Compiled slug size: 325.0MB is too large

What is slug?

Slugs are compressed and pre-packaged copies of your application optimized for distribution to thedyno manager. When you git push to Heroku, your code is received by the slug compiler which transforms your repository into a slug. Scaling an application then downloads and expands the slug to a dyno for execution.

What is this error about?

It means you code base is huge and compressing it should not exceed size 300 MB;

How to solve?

If your repository contains files not necessary to run your app, you may wish to add these to a.slugignore file in the root of your repository. Examples of files you may wish to exclude from the slug:

  • Unit tests or specs
  • Art sources (like .psd files)
  • Design documents (like .pdf files)
  • Test data

The format is roughly the same as .gitignore. Here’s an example .slugignore:

*.psd
*.pdf
/test
/spec

The .slugignore file causes files to be removed after you push code to Heroku and before thebuildpack runs. This lets you prevent large files from being included in the final slug. Unlike.gitignore, .slugignore does not support negated ! patterns.

If Still not fixed:

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

 

Mainly copied from

https://devcenter.heroku.com/articles/slug-compiler

http://stackoverflow.com/questions/30199856/heroku-compiled-slug-size-is-too-large/34498297#34498297

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s