BenoitAnastay / paperless-home-assistant-addon

Paperless Home Assistant Addon
MIT License
35 stars 7 forks source link

PermissionError: [Errno 13] Permission denied #189

Closed BernhardMaier closed 1 week ago

BernhardMaier commented 2 weeks ago

I recently installed the Add-On (v2.1.5) in Home Assistant (v2024.10.4 running in HA OS on a RasPi4), configured it, created a shared storage on my NAS, added this storage in HA and started the Add-On. It starts and has access to the storage (i see some newly created folders there), but it seems that the initial migration can't complete successfully because of permission issues.

The main error is the following: PermissionError: [Errno 13] Permission denied: '/share/paperless/media/media.lock'

The complete log looks like this:

  Applying documents.1055_alter_storagepath_path...Paperless-ngx docker container starting...
Installing languages...
Package tesseract-ocr-deu already installed!
Package tesseract-ocr-eng already installed!
Creating directory scratch directory /tmp/paperless
Adjusting permissions of paperless files. This may take a while.
changed ownership of '/share/paperless/media' from root:root to paperless:paperless
changed ownership of '/share/paperless/media/documents' from root:root to paperless:paperless
changed ownership of '/share/paperless/media/documents/originals' from root:root to paperless:paperless
changed ownership of '/share/paperless/media/documents/thumbnails' from root:root to paperless:paperless
changed ownership of '/share/paperless/consume' from root:root to paperless:paperless
Waiting for Redis...
Connected to Redis broker.
Apply database migrations...
Operations to perform:
  Apply all migrations: account, admin, auditlog, auth, authtoken, contenttypes, django_celery_results, documents, guardian, paperless, paperless_mail, sessions, socialaccount
Running migrations:
Traceback (most recent call last):
  File "/usr/src/paperless/src/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.11/dist-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/dist-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.11/dist-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.11/dist-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/django/core/management/commands/migrate.py", line 357, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/executor.py", line 255, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/operations/special.py", line 196, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/usr/src/paperless/src/documents/migrations/1055_alter_storagepath_path.py", line 15, in convert_from_format_to_template
    with transaction.atomic(), FileLock(settings.MEDIA_LOCK):
  File "/usr/local/lib/python3.11/dist-packages/filelock/_api.py", line 376, in __enter__
    self.acquire()
  File "/usr/local/lib/python3.11/dist-packages/filelock/_api.py", line 332, in acquire
    self._acquire()
  File "/usr/local/lib/python3.11/dist-packages/filelock/_unix.py", line 42, in _acquire
    fd = os.open(self.lock_file, open_flags, self._context.mode)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/share/paperless/media/media.lock'

Is this a known issue? If yes, how can i fix it? If not, how can i provide help to identify and solve it?

BenoitAnastay commented 2 weeks ago

You can change the UID and GID of paperless to match the owner of the host folder

BernhardMaier commented 2 weeks ago

Thanks for the advice. With a little help of ChatGPT i adjusted the IDs in the Config, but this not solved the problem, the same exception still occures. I use CIFS/SMB for the connection with the NAS, so i will try to change it to use NFS, maybe this can help.

BernhardMaier commented 1 week ago

Ok, got it to work and yes, using NFS instead of CIFS/SMB solved it.