Skip to content
Latchkey

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
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
# 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.

Terminal
python manage.py collectstatic --noinput --settings=myproject.settings.ci

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →