Skip to content

PermissionError due to unsynchronized migration files in PyPI release #137

Open
@954-Ivory

Description

@954-Ivory

Environment:

  • Python 3.12.8
  • Django 5.2.1
  • Error occurs in Docker environment
  • Works fine in local WSL development environment

When I run the command:

python manage.py makemigrations

Here are my relevant storage settings in settings.py:

STORAGES = {
    "default": {
        "BACKEND": "django.core.files.storage.FileSystemStorage",
    },
    "staticfiles": {
        "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
    },
    "import_export_celery": {
        "BACKEND": "protected_media.models.ProtectedFileSystemStorage",
    },
}

IMPORT_EXPORT_CELERY_STORAGE_ALIAS = 'import_export_celery'

Note: I am using the ProtectedFileSystemStorage class from django-protected-media as the storage backend for import_export_celery

I get the following output:

Migrations for 'import_export_celery':
  /usr/local/lib/python3.12/site-packages/import_export_celery/migrations/0011_alter_exportjob_id_alter_importjob_id.py
    ~ Alter field id on exportjob
    ~ Alter field id on importjob
Traceback (most recent call last):
  File "/app/manage.py", line 32, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/base.py", line 416, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/management/commands/makemigrations.py", line 260, in handle
    self.write_migration_files(changes)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/commands/makemigrations.py", line 366, in write_migration_files
    with open(writer.path, "w", encoding="utf-8") as fh:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.12/site-packages/import_export_celery/migrations/0011_alter_exportjob_id_alter_importjob_id.py'

Suggestions:

The latest migration file included in the PyPI release of the import_export_celery package appears to be 0010_auto_20231013_0904.py.

However, newer migration files from the source code, such as 0011_alter_exportjob_email_on_completion.py, do not seem to have been synchronized to the PyPI package.

Because of this, when running makemigrations, Django attempts to generate or modify migration files inside the site-packages directory, leading to permission errors—especially noticeable in Docker or other environments with restricted file permissions.

It would be ideal if these migration files were included and kept up-to-date in the PyPI package releases to prevent such issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions