Skip to content

ValueError: cannot mmap an empty file #914

Description

@kantord

When running in https://github.com/stacklok/toolhive

❯ seagoat-server start .

2025-05-20 13:04:01,182 Creating server...
2025-05-20 13:04:01,183 Starting worker thread...
2025-05-20 13:04:01,187 Serving on http://0.0.0.0:45787
2025-05-20 13:04:01,951 Checking repository for new changes
2025-05-20 13:04:01,984 Estimated ripgrep cache size: 0.00 megabytes (0 bytes). Line count 0
Exception in thread Thread-1 (_worker_function):
Traceback (most recent call last):
  File "/home/kantord/.local/share/pipx/venvs/seagoat/lib/python3.13/site-packages/seagoat/queue/base_queue.py", line 78, in _worker_function
    task = self._task_queue.get(timeout=0.1)
  File "/usr/lib/python3.13/queue.py", line 212, in get
    raise Empty
_queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/usr/lib/python3.13/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kantord/.local/share/pipx/venvs/seagoat/lib/python3.13/site-packages/seagoat/queue/base_queue.py", line 83, in _worker_function
    self.handle_maintenance(context)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/kantord/.local/share/pipx/venvs/seagoat/lib/python3.13/site-packages/seagoat/queue/task_queue.py", line 68, in handle_maintenance
    remaining_chunks_to_analyze = context["seagoat_engine"].analyze_codebase(
        self.kwargs["minimum_chunks_to_analyze"]
    )
  File "/home/kantord/.local/share/pipx/venvs/seagoat/lib/python3.13/site-packages/seagoat/engine.py", line 78, in analyze_codebase
    fetcher["cache_repo"]()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/kantord/.local/share/pipx/venvs/seagoat/lib/python3.13/site-packages/seagoat/sources/ripgrep.py", line 111, in cache_repo
    memory_cache.rebuild()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/kantord/.local/share/pipx/venvs/seagoat/lib/python3.13/site-packages/seagoat/sources/ripgrep.py", line 90, in rebuild
    self._data = mmap.mmap(cache_file.fileno(), 0)
                 ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot mmap an empty file
^CServer started at http://localhost:45787
Server running.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions