Django "collectstatic" fails: "STATIC_ROOT ... not been provided" in CI
collectstatic copies static files into STATIC_ROOT, so it fails when that setting is empty. In CI this happens when the settings module used for the collectstatic step does not define STATIC_ROOT (the dev settings often skip it).
What this error means
The collectstatic step fails with "django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path."
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app
without having set the STATIC_ROOT setting to a filesystem path.Common causes
STATIC_ROOT is not set in the CI settings
The settings module used in CI never defines STATIC_ROOT, so collectstatic has no destination directory.
A dev settings module without a collect target
Development serves static files directly and skips STATIC_ROOT; CI reuses that module for collectstatic.
How to fix it
Set STATIC_ROOT to a build path
Point STATIC_ROOT at a directory the job can write to before running collectstatic.
# settings/ci.py
from pathlib import Path
STATIC_ROOT = Path(__file__).resolve().parent.parent / "staticfiles"Run collectstatic non-interactively
Use the CI settings module and skip the prompt.
python manage.py collectstatic --noinput --settings=myproject.settings.ciHow to prevent it
- Define STATIC_ROOT in the settings module CI uses for collectstatic.
- Run collectstatic with --noinput in automation.
- Keep static configuration consistent between the collect and serve settings.