[GH-ISSUE #172] Permission denied when using NFS share for volumes #135

Closed
opened 2026-02-25 21:31:16 +03:00 by kerem · 2 comments
Owner

Originally created by @bwoodworth on GitHub (Oct 15, 2020).
Original GitHub issue: https://github.com/ciur/papermerge/issues/172

Originally assigned to: @ciur on GitHub.

Description
Fresh install using docker-compose. Volumes set like this:

volumes:
      - /mnt/papermerge/media_root:/opt/media

/mnt/papermerge/media_root is an NFS share. I also have IMPORTER_DIR="/opt/media/import" set in the conf.

When I place a document in the import directory I get the following error in the container log:

[2020-10-15 15:49:25,557: ERROR/ForkPoolWorker-2] Task papermerge.core.management.commands.worker.import_from_local_folder[f003d069-77a0-46f2-8f08-be2daa56f370] raised unexpected: PermissionError(13, 'Permission denied')
Traceback (most recent call last):
  File "/usr/lib/python3.8/shutil.py", line 788, in move
    os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: '/opt/media/import/document10142021.pdf' -> '/tmp/tmpl4dqqcw5/document10142021.pdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/app/.venv/lib/python3.8/site-packages/celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/opt/app/.venv/lib/python3.8/site-packages/celery/app/trace.py", line 650, in __protected_call__
    return self.run(*args, **kwargs)
  File "/opt/app/papermerge/core/management/commands/worker.py", line 53, in import_from_local_folder
    import_documents(settings.PAPERMERGE_IMPORTER_DIR)
  File "/opt/app/papermerge/core/importers/local.py", line 39, in import_documents
    shutil.move(file, tempdirname)
  File "/usr/lib/python3.8/shutil.py", line 803, in move
    os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/opt/media/import/document10142021.pdf'

Also, when I upload a document it appears to complete, but the document in the UI doesn't show any contents on any page. When I look in the physical location of the volume the document is not there.

Expected
Documents should import and upload successfully.

Actual
Permission denied error for imports and uploaded documents not completing successfully

Info:

  • OS: Debian 10 - Docker
  • Browser: N/A
  • Database: PostgreSQL 12.1
  • Papermerge Version: 1.5
Originally created by @bwoodworth on GitHub (Oct 15, 2020). Original GitHub issue: https://github.com/ciur/papermerge/issues/172 Originally assigned to: @ciur on GitHub. **Description** Fresh install using docker-compose. Volumes set like this: ``` volumes: - /mnt/papermerge/media_root:/opt/media ```` /mnt/papermerge/media_root is an NFS share. I also have IMPORTER_DIR="/opt/media/import" set in the conf. When I place a document in the import directory I get the following error in the container log: ``` [2020-10-15 15:49:25,557: ERROR/ForkPoolWorker-2] Task papermerge.core.management.commands.worker.import_from_local_folder[f003d069-77a0-46f2-8f08-be2daa56f370] raised unexpected: PermissionError(13, 'Permission denied') Traceback (most recent call last): File "/usr/lib/python3.8/shutil.py", line 788, in move os.rename(src, real_dst) OSError: [Errno 18] Invalid cross-device link: '/opt/media/import/document10142021.pdf' -> '/tmp/tmpl4dqqcw5/document10142021.pdf' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/app/.venv/lib/python3.8/site-packages/celery/app/trace.py", line 385, in trace_task R = retval = fun(*args, **kwargs) File "/opt/app/.venv/lib/python3.8/site-packages/celery/app/trace.py", line 650, in __protected_call__ return self.run(*args, **kwargs) File "/opt/app/papermerge/core/management/commands/worker.py", line 53, in import_from_local_folder import_documents(settings.PAPERMERGE_IMPORTER_DIR) File "/opt/app/papermerge/core/importers/local.py", line 39, in import_documents shutil.move(file, tempdirname) File "/usr/lib/python3.8/shutil.py", line 803, in move os.unlink(src) PermissionError: [Errno 13] Permission denied: '/opt/media/import/document10142021.pdf' ``` Also, when I upload a document it appears to complete, but the document in the UI doesn't show any contents on any page. When I look in the physical location of the volume the document is not there. **Expected** Documents should import and upload successfully. **Actual** Permission denied error for imports and uploaded documents not completing successfully **Info:** - OS: Debian 10 - Docker - Browser: N/A - Database: PostgreSQL 12.1 - Papermerge Version: 1.5
kerem 2026-02-25 21:31:16 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ciur commented on GitHub (Oct 15, 2020):

@bwoodworth, thank you for opening this bug report.

This is core of the issue:

OSError: [Errno 18] Invalid cross-device link: '/opt/media/import/document10142021.pdf' -> '/tmp/tmpl4dqqcw5/document10142021.pdf'

During import, just before creating file in media directory, application moves document into a temporary location first.
When importer_dir is in NFS, shutil.move( NFS node -> LOCAL FS) fails.
One way to fix this problem is by adding a configuration setting - with "temporary root" (e.g. /opt/tmp so that both /opt/tmp and /opt/media will be on same device)

<!-- gh-comment-id:709429565 --> @ciur commented on GitHub (Oct 15, 2020): @bwoodworth, thank you for opening this bug report. This is core of the issue: > OSError: [Errno 18] **Invalid cross-device link:** '/opt/media/import/document10142021.pdf' -> '/tmp/tmpl4dqqcw5/document10142021.pdf' During import, just before creating file in media directory, application moves document into a temporary location first. When importer_dir is in NFS, shutil.move( NFS node -> LOCAL FS) fails. One way to fix this problem is by adding a configuration setting - with "temporary root" (e.g. /opt/tmp so that both /opt/tmp and /opt/media will be on same device)
Author
Owner

@bwoodworth commented on GitHub (Oct 15, 2020):

I added the tmp location as a volume to docker-compose and did a chmod on the directories and it is working now.

<!-- gh-comment-id:709475020 --> @bwoodworth commented on GitHub (Oct 15, 2020): I added the tmp location as a volume to docker-compose and did a chmod on the directories and it is working now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/papermerge#135
No description provided.