[GH-ISSUE #901] Bug: Opening logfile fails with sshfs mounted filesystem #559

Closed
opened 2026-03-01 14:44:34 +03:00 by kerem · 3 comments
Owner

Originally created by @tuupola on GitHub (Dec 12, 2021).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/901

Describe the bug

Opening the logfile fails when archivebox is installed on Vagrant virtual machine and the archivebox folder is mounted with vagrant-sshfs.

$ archivebox add https://example.com
[i] [2021-12-12 21:51:05] ArchiveBox v0.6.2: archivebox add https://example.com
    > /vagrant/archivebox

Traceback (most recent call last):
  File "/home/vagrant/.local/bin/archivebox", line 8, in <module>
    sys.exit(main())
  File "/home/vagrant/.local/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 140, in main
    run_subcommand(
  File "/home/vagrant/.local/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 74, in run_subcommand
    setup_django(in_memory_db=subcommand in fake_db, check_db=cmd_requires_db and not init_pending)
  File "/home/vagrant/.local/lib/python3.10/site-packages/archivebox/config.py", line 1142, in setup_django
    with open(settings.ERROR_LOG, "a+", encoding='utf-8') as f:
PermissionError: [Errno 1] Operation not permitted: '/vagrant/archivebox/logs/errors.log'

This is most likely related to fuse and sshfs not being able to open the logfile a+ file mode.

https://github.com/ArchiveBox/ArchiveBox/blob/dev/archivebox/config.py#L1160

Unless there is a reason the logfile must be opened in read and write mode, the easy fix to open it on a ie. write mode only.

with open(settings.ERROR_LOG, "a", encoding='utf-8') as f:

ArchiveBox version

$ archivebox --version
ArchiveBox v0.6.2
Cpython Linux Linux-5.15.6-200.fc35.x86_64-x86_64-with-glibc2.34 x86_64
IN_DOCKER=False DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND_ENGINE=ripgrep

[i] Dependency versions:
 √  ARCHIVEBOX_BINARY     v0.6.2          valid     /home/vagrant/.local/bin/archivebox                                         
 √  PYTHON_BINARY         v3.10.0         valid     /usr/bin/python3.10                                                         
 √  DJANGO_BINARY         v3.1.14         valid     /home/vagrant/.local/lib/python3.10/site-packages/django/bin/django-admin.py
 √  CURL_BINARY           v7.79.1         valid     /usr/bin/curl                                                               
 √  WGET_BINARY           v1.21.2         valid     /usr/bin/wget                                                               
 X  NODE_BINARY           ?               invalid   node                                                                        
 X  SINGLEFILE_BINARY     ?               invalid   single-file                                                                 
 X  READABILITY_BINARY    ?               invalid   readability-extractor                                                       
 X  MERCURY_BINARY        ?               invalid   mercury-parser                                                              
 √  GIT_BINARY            v2.33.1         valid     /usr/bin/git                                                                
 √  YOUTUBEDL_BINARY      v2021.06.06     valid     /home/vagrant/.local/bin/youtube-dl                                         
 √  CHROME_BINARY         v94.0.4606.81   valid     /usr/bin/chromium-browser                                                   
 X  RIPGREP_BINARY        ?               invalid   rg                                                                          

[i] Source-code locations:
 √  PACKAGE_DIR           23 files        valid     /home/vagrant/.local/lib/python3.10/site-packages/archivebox                
 √  TEMPLATES_DIR         3 files         valid     /home/vagrant/.local/lib/python3.10/site-packages/archivebox/templates      
 -  CUSTOM_TEMPLATES_DIR  -               disabled                                                                              

[i] Secrets locations:
 -  CHROME_USER_DATA_DIR  -               disabled                                                                              
 -  COOKIES_FILE          -               disabled                                                                              

[i] Data locations:
 √  OUTPUT_DIR            5 files         valid     /vagrant/archivebox                                                         
 √  SOURCES_DIR           3 files         valid     ./sources                                                                   
 √  LOGS_DIR              1 files         valid     ./logs                                                                      
 √  ARCHIVE_DIR           2 files         valid     ./archive                                                                   
 √  CONFIG_FILE           81.0 Bytes      valid     ./ArchiveBox.conf                                                           
 √  SQL_INDEX             216.0 KB        valid     ./index.sqlite3                                                             

[!] Warning: Missing 5 recommended dependencies
    ! NODE_BINARY: node (unable to detect version)
    ! SINGLEFILE_BINARY: single-file (unable to detect version)
      Hint: To install all packages automatically run: archivebox setup
            or to disable it and silence this warning: archivebox config --set SAVE_SINGLEFILE=False
            
    ! READABILITY_BINARY: readability-extractor (unable to detect version)
      Hint: To install all packages automatically run: archivebox setup
            or to disable it and silence this warning: archivebox config --set SAVE_READABILITY=False
            
    ! MERCURY_BINARY: mercury-parser (unable to detect version)
      Hint: To install all packages automatically run: archivebox setup
            or to disable it and silence this warning: archivebox config --set SAVE_MERCURY=False
            
    ! RIPGREP_BINARY: rg (unable to detect version)
Originally created by @tuupola on GitHub (Dec 12, 2021). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/901 #### Describe the bug Opening the logfile fails when archivebox is installed on Vagrant virtual machine and the archivebox folder is mounted with `vagrant-sshfs`. ```logs $ archivebox add https://example.com [i] [2021-12-12 21:51:05] ArchiveBox v0.6.2: archivebox add https://example.com > /vagrant/archivebox Traceback (most recent call last): File "/home/vagrant/.local/bin/archivebox", line 8, in <module> sys.exit(main()) File "/home/vagrant/.local/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 140, in main run_subcommand( File "/home/vagrant/.local/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 74, in run_subcommand setup_django(in_memory_db=subcommand in fake_db, check_db=cmd_requires_db and not init_pending) File "/home/vagrant/.local/lib/python3.10/site-packages/archivebox/config.py", line 1142, in setup_django with open(settings.ERROR_LOG, "a+", encoding='utf-8') as f: PermissionError: [Errno 1] Operation not permitted: '/vagrant/archivebox/logs/errors.log' ``` This is most likely related to fuse and sshfs not being able to open the logfile `a+` file mode. https://github.com/ArchiveBox/ArchiveBox/blob/dev/archivebox/config.py#L1160 Unless there is a reason the logfile must be opened in read and write mode, the easy fix to open it on `a` ie. write mode only. ```python with open(settings.ERROR_LOG, "a", encoding='utf-8') as f: ``` #### ArchiveBox version <!-- Run the `archivebox version` command locally then copy paste the result here: --> ```logs $ archivebox --version ArchiveBox v0.6.2 Cpython Linux Linux-5.15.6-200.fc35.x86_64-x86_64-with-glibc2.34 x86_64 IN_DOCKER=False DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND_ENGINE=ripgrep [i] Dependency versions: √ ARCHIVEBOX_BINARY v0.6.2 valid /home/vagrant/.local/bin/archivebox √ PYTHON_BINARY v3.10.0 valid /usr/bin/python3.10 √ DJANGO_BINARY v3.1.14 valid /home/vagrant/.local/lib/python3.10/site-packages/django/bin/django-admin.py √ CURL_BINARY v7.79.1 valid /usr/bin/curl √ WGET_BINARY v1.21.2 valid /usr/bin/wget X NODE_BINARY ? invalid node X SINGLEFILE_BINARY ? invalid single-file X READABILITY_BINARY ? invalid readability-extractor X MERCURY_BINARY ? invalid mercury-parser √ GIT_BINARY v2.33.1 valid /usr/bin/git √ YOUTUBEDL_BINARY v2021.06.06 valid /home/vagrant/.local/bin/youtube-dl √ CHROME_BINARY v94.0.4606.81 valid /usr/bin/chromium-browser X RIPGREP_BINARY ? invalid rg [i] Source-code locations: √ PACKAGE_DIR 23 files valid /home/vagrant/.local/lib/python3.10/site-packages/archivebox √ TEMPLATES_DIR 3 files valid /home/vagrant/.local/lib/python3.10/site-packages/archivebox/templates - CUSTOM_TEMPLATES_DIR - disabled [i] Secrets locations: - CHROME_USER_DATA_DIR - disabled - COOKIES_FILE - disabled [i] Data locations: √ OUTPUT_DIR 5 files valid /vagrant/archivebox √ SOURCES_DIR 3 files valid ./sources √ LOGS_DIR 1 files valid ./logs √ ARCHIVE_DIR 2 files valid ./archive √ CONFIG_FILE 81.0 Bytes valid ./ArchiveBox.conf √ SQL_INDEX 216.0 KB valid ./index.sqlite3 [!] Warning: Missing 5 recommended dependencies ! NODE_BINARY: node (unable to detect version) ! SINGLEFILE_BINARY: single-file (unable to detect version) Hint: To install all packages automatically run: archivebox setup or to disable it and silence this warning: archivebox config --set SAVE_SINGLEFILE=False ! READABILITY_BINARY: readability-extractor (unable to detect version) Hint: To install all packages automatically run: archivebox setup or to disable it and silence this warning: archivebox config --set SAVE_READABILITY=False ! MERCURY_BINARY: mercury-parser (unable to detect version) Hint: To install all packages automatically run: archivebox setup or to disable it and silence this warning: archivebox config --set SAVE_MERCURY=False ! RIPGREP_BINARY: rg (unable to detect version) ``` <!-- Tickets without full version info will closed until it is provided, we need the full output here to help you solve your issue -->
kerem closed this issue 2026-03-01 14:44:34 +03:00
Author
Owner

@pirate commented on GitHub (Dec 15, 2021):

Do you want to open a PR with the fix so you get contributor credit for it? 😉

<!-- gh-comment-id:994257945 --> @pirate commented on GitHub (Dec 15, 2021): Do you want to open a PR with the fix so you get contributor credit for it? 😉
Author
Owner

@tuupola commented on GitHub (Dec 15, 2021):

Yep, I can do it.

<!-- gh-comment-id:994745647 --> @tuupola commented on GitHub (Dec 15, 2021): Yep, I can do it.
Author
Owner

@tuupola commented on GitHub (Dec 21, 2021):

Fixed by #906.

<!-- gh-comment-id:999058236 --> @tuupola commented on GitHub (Dec 21, 2021): Fixed by #906.
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/ArchiveBox#559
No description provided.