qgis-plugin
qgis-plugin copied to clipboard
[windows] FileNotFoundError when writing a file during sync
Traceback (most recent call last):
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\sync_dialog.py", line 294, in pull_timer_tick
is_running = pull_project_is_running(self.job)
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\mergin\client_pull.py", line 447, in pull_project_is_running
raise future.exception()
File "C:\PROGRA~1\QGIS 3.18\apps\Python37\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\mergin\client_pull.py", line 86, in _do_download
item.download_blocking(mc, mp, project_path)
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\mergin\client_pull.py", line 281, in download_blocking
save_to_file(resp, self.download_file_path)
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\mergin\utils.py", line 36, in save_to_file
with open(path, 'wb') as output:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Dropbox (HGC)\\MEG21001 2021 Christina Lake Wetland Monitoring\\2.0 Env and Regulatory\\Fieldwork\\02 June Spring Field Program\\Mergin Field Data\\MEG210001 - Spring Program\\.mergin\\fetch_v1-v3\\Spring_2021_Program_Sites.gpkg-diff-46e8c9de-fa2f-4030-9c66-07adfafd5516.0'
hi @CamMakoJ thanks for the bug report.
As strange as it sounds in 2021, it looks like your path is too long. On Windows there are limits in some places for paths to be max. 260 characters long... The path that is giving the error is exactly 262 characters long, hence my suspicion. Could you please try to move your Mergin project to a place with shorter path and try again?
Resources: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
Hrmm so i tried decreasing the file length and that still didn't work. here is another example from a another form i tried to run with a much shorter file name:
Traceback (most recent call last):
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\sync_dialog.py", line 310, in pull_timer_tick self.pull_conflicts = pull_project_finalize(self.job)
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\mergin\client_pull.py", line 513, in pull_project_finalize file_to_merge.merge()
File "C:/Users/Cam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\mergin\client_pull.py", line 481, in merge os.remove(item.download_file_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\Dropbox (HGC)\GIS\Data\Mergin\MEG21001-Spring Monitoring\.mergin\fetch_v3-v4\MEG21001-Spring Monitoring.gpkg-diff-b9f39b67-0aa6-4c33-a0fa-e2539a312591.0'
Hmm that's a different error now - about permissions. I believe this could be due to the fact that it's in a Dropbox folder - dropbox may be reading the temporary file and the operating system blocks us to delete the temporary file. Could you please try again in a folder not managed by dropbox?
Ok so after trying a few things i think its both errors - the filenames originally, but also dropbox. i just 'paused' dropbox before syncing mergin and it worked no problem.
Great to hear that helped!
I guess we can close this ticket :)