Error on opening files from a mounted remote drive

New to LibreOffice. I am using Zorin 16 Linux OS (built on Ubuntu 20.04.3 LTS) and RClone as a method to mount OneDrive. I can access the drive and can open certain files (eg PDF files). But I cannot open docx, xlsx or pptx files. The file is recognized in the directory as an MSOffice file but is accessed by LibreOffice as a text import file. When opening the file, an error message is returned: Document Cannot be Locked. The file is most definitely not corrupted. I can copy the file to the desktop and Libreoffice will open the file without error. This seems to be an incompatibility or a permission issue between LibreOffice and OneDrive.

This most probably means: You are not allowed to create hidden files on your remote drive. LibreOffice tries to create a lock file .~lock.<filename># as soon as you open a file for editing. Some remote services prohibit to create such hidden files (all files starting with a . [dot] are considered “hidden”). As a (bad) workaround, you may want to disable file locking - see: How to disable file locking on linux (Ubuntu) - Permanently

Not using OneDrive, hence cannot test myself, but you may try to put your files into subfolders instead of using OneDrive’s root folder. Some remote services allow creating hidden files in subfolders but not in root folder.

Aside Do not use docx, xlsx or pptx as your default file formats when working with LibreOffice, if you don’t have very, very good reasons to do so. Turn to ODF format, use files in that format as your master documents, and export to other formats in case someone insists on that other format. Absolutely don’t convert from one format to another back and forth. Sooner or later you’ll get into trouble.

1 Like

I have found no evidence in MS Support that OneDrive prevents the creation of hidden files on OneDrive. In fact when I checked my OneDrive account activity, a lock file was reported as being created but then deleted, likely as the operation was canceled. The location of the file in any particular folder did not change the behavior of the program. I also saved the file into OneDrive as an ODS file. That also did not correct the problem. I am also struck with the fact that LibreOffice attempted to import the files as a Unicode text file. That behavior is peculiar.
One last look into the mounting of the Drive. Is it possible that RClone is causing the issue?

All docx, xlsx, pptx, odt, ods and odp files have one thing in common: they are zip container files. If they open instead as some garbage text import but otherwise if copied somewhere else first open fine, it is an indicator that OneDrive or RClone in between interferes and maybe tries to fiddle with zip files when accessing them directly, or files can not be accessed at random file positions. You could try to execute the command
unzip -t /path/to/fileononedrive.xlsx
that tests the zip file content, if it fails it is an indicator that something is going wrong, but if it does not fail it does not proof much, just that the zip file can be read as stream (which LibreOffice can as it apparently opens the zip stream in Writer).