1

I have a Django app with a React frontend deployed on Heroku. When I try to make changes then run

python ../manage.py collectstatic

it seems to be post-processing an infinite amount of files. It just goes on forever until it finally times out.

When I run the same command in my development mode everything works fine. I can't figure out what's wrong. Is the files being brought over incorrectly?

Here is the full message:

Post-processing 'All' failed!

Traceback (most recent call last):
  File "../manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 189, in handle
    collected = self.collect()
  File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 135, in collect
    raise processed
RuntimeError: Max post-process passes exceeded.

npm ERR! Linux 5.0.0-37-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "collectstatic"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! frontend-app@0.1.0 collectstatic: `python ../manage.py collectstatic --no-input`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend-app@0.1.0 collectstatic script 'python ../manage.py collectstatic --no-input'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the frontend-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     python ../manage.py collectstatic --no-input
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs frontend-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls frontend-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/hzren/github_workspace/tracy_and_brian_website/src/frontend-app/npm-debug.log

npm ERR! Linux 5.0.0-37-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "collect"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! frontend-app@0.1.0 collect: `react-scripts build && npm run build-rename && npm run copy-buildfiles && npm run collectstatic`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend-app@0.1.0 collect script 'react-scripts build && npm run build-rename && npm run copy-buildfiles && npm run collectstatic'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the frontend-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-scripts build && npm run build-rename && npm run copy-buildfiles && npm run collectstatic
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs frontend-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls frontend-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

Here are the relevant information from my settings.py

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__))


STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'staticfiles'), 
]

STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'staticfiles')

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.CachedStaticFilesStorage"


MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media_cdn')
MEDIA_URL = '/media_cdn/'

AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None

AWS_QUERYSTRING_AUTH = False

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

django_heroku.settings(locals())

Thanks so much in advance!

able-leopard
  • 115
  • 1
  • 14
  • 1
    Could you please also post the relevant staticfiles config? Any chance you are using a third-party app in conjunction with staticfiles? In other words, open a Django shell in heroku (`python manage.py shell`) and repost to us the following settings: `'STATICFILES_DIRS', 'STATICFILES_FINDERS', 'STATICFILES_STORAGE', 'STATIC_ROOT', 'STATIC_URL',` – Brian Dant Dec 14 '19 at 21:49
  • @BrianDant Thanks for your comment. I have edited the post and added the relevant info. – able-leopard Dec 14 '19 at 23:19
  • 1
    I'd start by a) dropping the `STATICFILES_STORAGE = "django.contrib.staticfiles.storage.CachedStaticFilesStorage"`; staticfiles will then [fallback to](https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-STATICFILES_STORAGE) the more basic`StaticFilesStorage` class. This will remove complexity on Heroku. Then, is it possible not to use the `django_heroku` app? Then, ask yourself, what are the differences between my local env and Heroku? (The `django_heroku` app is on obvious answer.) – Brian Dant Dec 14 '19 at 23:30
  • @BrianDant Thank you. I'll have to dig a bit deeper, but your explaination was really helpful! – able-leopard Dec 15 '19 at 18:06
  • @able-leopard Did you resolve this? I've just come across this on a project that's had no issues collecting static until now when I've hit this error and I don't understand why. – markwalker_ Mar 16 '22 at 01:50

0 Answers0