[Solved] Document Could Not Be Locked

Issues with installing under all GNU/Linux Distributions
Post Reply
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

[Solved] Document Could Not Be Locked

Post by Oskar4U »

In Linux Cinnamon 21.3 I created 2 Desktop Launchers to open 2 spreadsheet files which both are password protected. In my Windows11 laptop the same files I click on the shortcut, type the pass and it opens. In LibreOffice I click the launcher and a window opens and says:

"Document Could Not be Locked. The lock file could not be created for exclusive access by LibreOffice due to missing permissions to create lock file......" This window has 3 options, Open Read Only, Notify and Cancel.

When I click "Open Read Only" I type the pass and it opens the document as read only
When I click "Notify" the document opens again as read only, I dont see anything about Notify

So what is this lock file and how I can open my document like I do in Windows11 ?

Posted same question in Linux forum but I dont expect any help in there
Thanks

 Edit: Changed subject, was Could Not Create Lock File? 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Last edited by robleyd on Sun Jan 28, 2024 11:11 am, edited 3 times in total.
Reason: Add green tick
Nicolas
LibreOffice 7.5.4.2 in Windows11
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Could Not Create Lock File?

Post by robleyd »

The lock file is normally created by Open/LibreOffice in the same directory as the 'main' file; so in which directory is the file to which the launcher points? There may also be the same information in the complete error message, which you appear to have truncated in your question? You - the user name logged in - need have write permission in that directory.
Posted same question in Linux forum but I dont expect any help in there
I don't see it in the Linux section of this forum, so I take it you mean some other of the multitude of Linux oriented forums out there.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Could Not Create Lock File?

Post by Oskar4U »

Thanks for your time, the launchers point to the same directory where I have both files and in that directory I dont see any other file, I just have the 2 files I work. I went a set "open as root" the directory where both files are and the same message appears. BTW in my Windows11 where I have the same files I see no other files related to any "lock".
I attach copy of the window I get
LOCK FILE 2024-01-26 22-50-34.png
LOCK FILE 2024-01-26 22-50-34.png (28.3 KiB) Viewed 2984 times
Nicolas
LibreOffice 7.5.4.2 in Windows11
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Document Could Not Be Locked

Post by robleyd »

so in which directory is the file to which the launcher points
Check the file permissions for that directory and tell us what is the directory and what the file permissions are.
BTW in my Windows11 where I have the same files I see no other files related to any "lock".
The lock files will only be present when a Libre/OpenOffice file is open, be it Calc, Writer or some other type of document and will have a name of the form .~lock.xxx.yyy# where xxx will be the file name and .yyy will be the file extension. Note also that in both Windows and Linux these files are by default hidden and you will need to set the relevant file manager properties to allow viewing them.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Document Could Not Be Locked

Post by Oskar4U »

The files are in /home/nf/NF Utilities and the permissions are Read and Write

Now that I know where the lock file is and is only visible when the file is open I was able to copy the lock file in the Windows11 and paste it in the Linux directory where the same file is located but did not solve the problem Perhaps going from Windows11 to Linux is no appropriate but I just tried.

Bottom line is there a way to copy a LO calc file from Windows11 to Linux and having it working properly or we just wasting time?
How about if I create a new calc file in Linux with another name and copy the contents of the lock file into the new file?

Thanks
Nicolas
LibreOffice 7.5.4.2 in Windows11
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Document Could Not Be Locked

Post by RoryOF »

A lock file is a hidden file in all operating systems, so to see it one needs to enable viewing of hidden files. A left-over lock file, perhaps caused by a program or computer crash, will prevent a new lock file being written for the same OpenOffice file. Insufficient rights in a folder, often caused by Windows updates, can also prevent a lock file being written.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Document Could Not Be Locked

Post by robleyd »

The files are in /home/nf/NF Utilities and the permissions are Read and Write
There will, as usual for Linux, be three levels of permissions on any directory, in addition to its ownership. For instance, if I create a directory NF Utils in my home directory:
huntsman@dionysus:~$ mkdir 'NF Utils'
huntsman@dionysus:~$ ls -ld 'NF Utils'
drwxr-xr-x 2 huntsman users 4096 Jan 27 20:32 NF\ Utils/
I see that user huntsman has read, write and execute permissions on that directory, but others only have write and execute. So, if you open a terminal and issue the command

Code: Select all

ls -ld 'NF Utilities'
what do you see? And what user is trying to create lock files in that directory? If it isn't user nf, then they have no permission to write in that directory.

On a side note, do try and avoid spaces in file and directory names if possible as they can turn round and bite you if you don't know what you are doing.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Document Could Not Be Locked

Post by RoryOF »

If one wishes long filenames, best to use CamelCase and replace spaces with underscores.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Document Could Not Be Locked

Post by robleyd »

Here is a useful resource for information about Linux permissions.

You might also want to read a bit more about Linux basics
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
Hagar Delest
Moderator
Posts: 32668
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Document Could Not Be Locked

Post by Hagar Delest »

Oskar4U wrote: Sat Jan 27, 2024 11:52 am Bottom line is there a way to copy a LO calc file from Windows11 to Linux and having it working properly or we just wasting time?
Of course it is possible. The issue seems to be with the method you use to access the file.
Is it a shared folder on a dual boot machine?
If you copy the file and put it in elsewhere, does it open correctly?
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Document Could Not Be Locked

Post by Oskar4U »

Thanks for the help,
It is not a shared folder neither a dual boot machine.
Have no problem open the file in my Windows11 laptop
When I copy the file and paste in my Linux desktop I get the "....file is locked...." and it is read only
The permissions of this file in Linux are all Read and Write

What I just did in my Windows laptop I rename the file with just one word (someone here mentioned about length of file name), found the .lock file in my root and deleted the .lock file. Then I copy the file into Linux and the same problem exist

Kind of strange
Nicolas
LibreOffice 7.5.4.2 in Windows11
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Document Could Not Be Locked

Post by Oskar4U »

Reading the web I think I got it.

I copy the file in my Windows11 desktop and then deleted the file from its original location. Now I open the desktop .calc file and Options/ LibreOffice, Advanced - Open Expert config and searching for ?UseLocking", Then I change its properties from true to false and save the file.

Now I copy this file to Linux in my Home directory and make a launcher to open the file but it doesnt work unless I set my Home directory to "Open as Root". So I delete the file and place it in my Desktop folder and now it works.

I would like to keep this file in my Home directory so if anyone knows how to do it please let me know
Thanks
Nicolas
LibreOffice 7.5.4.2 in Windows11
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Document Could Not Be Locked

Post by RoryOF »

I think it is reasonable to say that an ordinary user (i.e. one not doing multiple accesses to the sane file) should never need to disable file locking. If doing so solves an access problem, there may be some error of working or of system configuration.

If an OpenOffice file is copied while open and transferred to another machine, it is possible that the hidden lock file is transferred with it, which means it may not open on the other machine without intervention.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Hagar Delest
Moderator
Posts: 32668
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Document Could Not Be Locked

Post by Hagar Delest »

Well, there is something clearly wrong here.
What is the file type exactly? You still refer to a .calc, that has no meaning for a Cal file. It should be .ods.
Deactivating the locking feature is not something recommended. And tweaking/deleting the lock files makes no sense at all. Same for opening the file as root.
If there is no sensitive data, can you upload the file somewhere so that we have a look?
Or are you able to reproduce the issue with a brand new file that you can share?
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Document Could Not Be Locked

Post by robleyd »

So, if you open a terminal and issue the command

Code: Select all

ls -ld 'NF Utilities'
what do you see? And what user is trying to create lock files in that directory? If it isn't user nf, then they have no permission to write in that directory.
The question of directory permissions for the location of the Calc file has still not been addressed. Remember that in Linux, a file can have all permissions but not be accessible because of directory level permissions.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Bill
Volunteer
Posts: 8934
Joined: Sat Nov 24, 2007 6:48 am

Re: Document Could Not Be Locked

Post by Bill »

Oskar4U wrote: Sat Jan 27, 2024 11:52 am The files are in /home/nf/NF Utilities and the permissions are Read and Write
Are write permissions enabled for the folder? If I turn off write permission for the folder, then I get your error message when trying to open files in the folder.
Oskar4U wrote: Sat Jan 27, 2024 11:52 am Now that I know where the lock file is and is only visible when the file is open I was able to copy the lock file in the Windows11 and paste it in the Linux directory where the same file is located but did not solve the problem Perhaps going from Windows11 to Linux is no appropriate but I just tried.
Moving the lock file from Windows to Linux isn't the solution. That will also prevent opening the file on Linux but it will display a different error message.
AOO 4.1.14 on Ubuntu MATE 22.04
oskar270
Posts: 30
Joined: Fri Oct 03, 2014 2:13 am
Location: Montreal, Canada

Re: Document Could Not Be Locked

Post by oskar270 »

Answer to one of the questions
nf@nf-OptiPlex-3050:~$ ls -ld 'NF Utilities'
drwxr-xr-x 2 root root 4096 Jan 27 13:32 'NF Utilities'
nf@nf-OptiPlex-3050:~$
Sorry about the files ID, they are not .calc, they are .ods

The Linux desktop is a dedicated pc for Linux where I learn how Linux works including LibreOffice. There is no network and I'm the only one using this pc including my laptop. As I mentioned in my last post both files are now working as they should be except they are located in my desktop directory which I do not like but eventually I will resolve this issue, not important for now.
Nicolas
OpenOffice 4.1 on Windows 8.1
User avatar
Hagar Delest
Moderator
Posts: 32668
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Document Could Not Be Locked

Post by Hagar Delest »

Only root has access to that folder. You have to change the ownership of the folder. Give it to you and it will be fine.

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the 🖉 button if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Document Could Not Be Locked

Post by robleyd »

It would seem you created the NF Utilities folder as user root; this is a classic example of why you shouldn't do anything as root without understanding the possible consequences.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Document Could Not Be Locked

Post by Oskar4U »

Can you tell me how do I change the ownership of my NF Utilities?
Thanks
Nicolas
LibreOffice 7.5.4.2 in Windows11
Bill
Volunteer
Posts: 8934
Joined: Sat Nov 24, 2007 6:48 am

Re: Document Could Not Be Locked

Post by Bill »

Open your file manager (Nemo?) as root. Navigate to the folder containing "NF Utilities". Right-click "NF Utilities" and select Properties. On the Properties dialog select the Permissions tab. There you should be able to change the owner and permissions for "NF Utilities".
AOO 4.1.14 on Ubuntu MATE 22.04
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Document Could Not Be Locked

Post by Oskar4U »

Thank you Bill, what you described I can do with no problem however the problem comes from a Launcher I have to open a file in the NF Utilities directory. When I click the launcher, it tries to open a file in NF Utilities directory but it cant open it because to access the file I must open the NF Utilities as root and I guess the Launcher cant do this. I know I can change the NF Utilities directory with the terminal command chmode but I'm not familiar with all the details of this command
Nicolas
LibreOffice 7.5.4.2 in Windows11
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Document Could Not Be Locked

Post by robleyd »

chmod is for changing permissions. You want to change the ownership of the directory without needing to change permissions; once ownership is granted to nf the problem will likely go away. It may be that the files in the directory are also owned by root; this being the case you would need to change ownership for them as well. You can do this with your file manager as mentioned by Bill.

If you want to do this from the command line open a terminal and from your (nf) home directory:

Code: Select all

sudo chown -R nf:users 'NF Utilities'
sudo will allow you to run chown as root which you need to do as root owns the directory. I expect sudo should prompt you for the root password, unless you have configured sudo to allow you to run it without password.

Once the directory and files are owned by user nf there will no longer be a problem and you won't need any foolish root stuff in your launcher.

Please find some time to look at the links I provided earlier.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: Document Could Not Be Locked

Post by Oskar4U »

Many thanks David for your time, that did the trick and now all is good, much appreciated.

I did read "briefly" the links you provided earlier for "useful resource + Linux basics". I have been learning Windows since the mid 80's and still learning and only started on Linux / LibreOffice about 2 years ago and that's part time. It takes time + practice to learn an OS and that's what I'm doing.
Cheers
Nicolas
LibreOffice 7.5.4.2 in Windows11
User avatar
Hagar Delest
Moderator
Posts: 32668
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] Document Could Not Be Locked

Post by Hagar Delest »

Sure but ownership for GNU/Linux systems are really basics you should learn first.
Anytime root is required, be aware that security is at stake. That's why using root for a simple and standard operation is not good at all.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Oskar4U
Posts: 71
Joined: Thu Mar 18, 2021 1:30 am
Location: Quebec, Canada

Re: [Solved] Document Could Not Be Locked

Post by Oskar4U »

I understand, thank you
Nicolas
LibreOffice 7.5.4.2 in Windows11
Post Reply