Skip to content

Bug: Opening logfile fails with sshfs mounted filesystem #901

@tuupola

Description

@tuupola

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)

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