0

I'm using Emacs with org-mode and the org-id option under Microsoft Windows 10.

GNU Emacs 29.2 (build 2, x86_64-w64-mingw32) of 2024-01-18

Org mode version 9.6.15 (release_9.6.15 @ c:/Program Files/Emacs/emacs-29.2/share/emacs/29.2/lisp/org/)

When I use the "Saving all org buffers" command by hitting "s" in an agenda view, the following error message is shown in the 'Warnings' buffer:

Warning (unlock-file): Unlocking file: Invalid argument, c:/Users/myusername/Documents/directoryname/.emacs.d/.org-id-locations, ignored

So it seems to be related to the file '.org-id-locations' and this is very annoying, as the Warnings buffer pops up each time when I save my changes..

This only happens after I have created a new org-mode heading and created a link to it, so that a new property value ':ID:' has been created..

However this even happens if the new heading is not displayed in the agenda, from where I'm saving, nor does the warning appear, when I just save the .org file with the new headings and properties...

How can I narrow down this annoying problem?

How can I narrow down the problem?

7
  • 1
    What happens if you say M-: (unlock-file "c:/Users/myusername/Documents/directoryname/.emacs.d/.org-id-locations") RET? Is there a buffer visiting that file perhaps? If there is, try killing the buffer (get a backup before and after saving that buffer too, just in case) and see if the warning goes away. Commented Feb 21, 2024 at 16:27
  • 1
    There is a dot in the name .org-id-locations, so please check again carefully. Also, add the backtrace to your question between triple backticks (the key to the left of the 1 key) so that it will be somewhat readable. Did you use the double quotes in the expression, exactly as I showed you in my comment above? Just cut and paste the expression as is, but if you type it in, make sure it's exactly as shown. Commented Feb 22, 2024 at 15:40
  • @NickD thank you again and sorry, if I'm doing something wrong.. I copied the following line into an empty buffer and did Ctrl-C Ctrl-E for evaluating the buffer, is that what you meant? '(unlock-file "c:/Users/myuser/Documents/mydirectory/.emacs.d/.org-id-locations")' the only result was a warning, this time: 'Warning (unlock-file): Unlocking file: Invalid argument, c:/Users/myuser/Documents/mydirectory/.emacs.d/.org-id-locations, ignored' Commented Feb 23, 2024 at 17:16
  • @NickD this time, there was no Backtrace, last time it was : ´´´Debugger entered--Lisp error: (void-variable c:/Users/myuserDocuments/mydirectory/.emacs.d/.org-id-locations) (unlock-file c:/Users/myuser/Documents/mydirectory/.emacs.d/.org-id-locations) (progn (unlock-file c:/Users/myuserDocuments/mydirectory/.emacs.d/.org-id-locations)) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) command-execute(eval-last-sexp) There is no open buffer with the file org-id-locations´´´ Commented Feb 23, 2024 at 17:18
  • 1
    I seem to have dropped the ball here: my apologies. Did you resolve this problem or are you still living with it? If you are still suffering and you'd like to continue debugging (after 7 months :-( ), ping me. The only reason I saw it again was the recently posted answer (which is one solution to the problem, although my preference would be to find the underlying reason for the problem and fix that). Commented Sep 23, 2024 at 17:07

1 Answer 1

3

Ahoy!

I am using emacs on a fresh upgrade of Ubuntu version 24.04. I didnt have this problem before the upgrade, but after the upgrade whenever I opened any file in emacs I got the following error.

Warning (unlock-file): Unlocking file: Invalid argument 

And then it would tell me the name and path of the file I had opened. It turns out emacs now has some builtin code to lock files I think specifically on an NFS to keep two people from editing the same file at once. It might be a good idea if it worked, but it just spits out like 10 of these warning messages.

Apparently there is a new flag that controls this behavior called create-lockfiles. Wherever you open a file, say file.txt. Emacs will create a lockfile called .#file.txt. Because it is a dotfile you can not see this file unless you run ls -a. Maybe because I am working on an NFS, but emacs will just give a million "Unlocking File" errors. Here is the relevent article in the GNU Emacs Lisp Reference Manual

https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Locks.html

To disable this lockfile behavior, open your ~/.emacs.d/init.el file and put in the following lines

;;fix lockfile warning (setq-default create-lockfiles nil) 

This will tell emacs not to create the lockfiles anymore. Then go to the directory where you opened the file, run ls -a, and look for any .#filename type files and erase those. That cleared up the warnings for me. Strange error but glad its finally working again.

Good luck!

1
  • thank you sooo much - this solved the problelm (also in MS Windows) and the annoying warnings are finally gone. :-) Commented Oct 23, 2024 at 13:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.