Project history and Remove locally fail in projects with long paths on Windows (> 260 characters)

Open
#967 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
desktop

Research direction

Both failures are long-path (>260 char) issues: Mergin/diff.py near line 386 (make_version_changes_layers) opens the cached .mergin/.cache/...schema.json, and Mergin/data_item.py line 215 (_delete_project_dir) walks the cache to delete it. Reproduce with the PowerShell snippet, then trace how those paths are built and where Windows long-path handling is missing. Done when Project history opens without the dialog and Remove locally deletes the folder completely.

Written by the indexing model from the issue text.

Description

bug windows

Description
In a project stored in a long folder on Windows, syncing works, but two plugin features show FileNotFoundError:

  • Project history: an error dialog appears when the window opens. After closing it, the history shows the changes.
  • Remove locally: an error appears and the project folder is left partly deleted.

It happens when files in the project's .mergin folder exceed 260 characters. In short-path projects both features work without errors.

Environment
[x] Staging [x] PROD

Application (+ app version, build, operating system)
QGIS 3.44.15-Solothurn, Mergin Maps plugin master (python-api-client 0.15.1, geodiff 2.3.2), Windows 11 64-bit Arm. LongPathsEnabled = 1 and 0 (same result).

Steps to reproduce

  1. On Windows, create a folder about 215 characters long, e.g. in PowerShell:
    $target = 215; $p = "C:\mmlong"
    while ($p.Length + 51 -le $target) { $p = Join-Path $p ("a"*50) }
    $p = Join-Path $p ("b" * ($target - $p.Length - 1))
    New-Item -ItemType Directory -Path $p -Force | Out-Null; $p.Length
    
  2. In QGIS, Browser → Mergin Maps → right-click a project with a GeoPackage → Download into that folder.
  3. Open the project, add a feature to the GeoPackage layer, save and sync.
  4. Click Project history on the Mergin Maps toolbar.
  5. Close the error dialog, the history window and the project (Project → Close).
  6. In the Browser, right-click the project → Remove locally.

Actual results

  • Step 4: an error dialog appears when the history window opens. After closing it, the history shows the changes.
    FileNotFoundError: [Errno 2] No such file or directory: '…\issue954_lv95\.mergin\.cache\v22\observations.gpkg-schema.json'
      File "Mergin\diff.py", line 386, in make_version_changes_layers
    
  • Step 6: an error appears and the project folder isn't fully removed (17 files left):
    FileNotFoundError: [WinError 3] The system cannot find the path specified: '…\issue954_lv95\.mergin\.cache\v25\observations.gpkg'
      File "Mergin\data_item.py", line 215, in _delete_project_dir
    

Expected results

  • Step 4: Project history opens without an error, as in short-path projects.
  • Step 6: The local project folder is removed completely, as in short-path projects.

Screenshots or logs

An error has occurred while executing Python code: 

FileNotFoundError: [Errno 2] No such file or directory: 'C:/mm932/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bb/issue954_lv95\\.mergin\\.cache\\v22\\observations.gpkg-schema.json' 
Traceback (most recent call last):
  File "C:\Users/mrcic/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\version_viewer_dialog.py", line 589, in selected_version_changed
    self.show_version_changes(version)
  File "C:\Users/mrcic/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\version_viewer_dialog.py", line 676, in show_version_changes
    layers = make_version_changes_layers(QgsProject.instance().homePath(), version)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users/mrcic/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\diff.py", line 386, in make_version_changes_layers
    with open(schema_file, encoding="utf-8") as fl:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:/mm932/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bb/issue954_lv95\\.mergin\\.cache\\v22\\observations.gpkg-schema.json'


Python version: 3.12.15 (main, Oct  2 2026, 17:29:02) [MSC v.1944 64 bit (AMD64)] 
QGIS version: 3.44.15-Solothurn Solothurn, 44b4ef05178 

Conclusion
Created by Claude and supervised by a human test analyst.

Dominant language
Python
Stars
45
Forks
21
Avg merge
3d 13h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MerginMaps/qgis-plugin

All issues in MerginMaps/qgis-plugin

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.