Opened 66 minutes ago
Last modified 63 minutes ago
#37188 assigned Bug
compilemessages should ignore common environment and dependency directories by default
| Reported by: | Ayoub Bouaik | Owned by: | Ayoub Bouaik |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | i18n, compilemessages, venv, node_modules |
| Cc: | Ayoub Bouaik | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
The compilemessages management command recursively traverses the entire project tree looking for locale directories. However, it currently lacks default ignore patterns for common python virtual environments (venv, .venv, env, .env) and modern frontend package management directories (node_modules).
Because of this, if a project contains a third-party package inside node_modules or a local virtual environment that includes localized files with formatting quirks (such as a Byte Order Mark), compilemessages attempts to process them, resulting in unexpected execution overhead or critical crashes on files the developer did not write.
Steps to Reproduce
Inside a clean project workspace, run the following commands to simulate a third-party dependency with a BOM-encoded translation file:
- Create a dummy package locale path:
mkdir -p node_modules/mock-package/locale/en/LC_MESSAGES/
- Add a dummy translation file containing a UTF-8 BOM flag:
printf '\xEF\xBB\xBF# Dummy translation file\nmsgid ""\nmsgstr ""\n' > node_modules/mock-package/locale/en/LC_MESSAGES/django.po
- Attempt to compile messages:
python manage.py compilemessages
Expected Behavior
Django should automatically skip top-level dependency and virtual environment folders like node_modules, venv, and .venv unless explicitly instructed otherwise via the -i / --ignore CLI flags.
Actual Output / Traceback
The /home/ayoub/django_test/node_modules/mock-package/locale/en/LC_MESSAGES/django.po file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.
CommandError: compilemessages generated one or more errors.