Ihor,
I am still puzzled why you can not reproduce messed version compilation
issue. I can not figure out what I am missing. I think, the case below
is easier than dealing with packages:
Consider the following file compile-broken.el where ~/src/org-mode
contains git main HEAD version:
(load "org")
(let ((org-dir "~/src/org-mode/lisp"))
(add-to-list 'load-path org-dir)
(byte-recompile-directory org-dir 0 :force))
remove lisp/*.elc files, run "make autoloads" and
emacs -Q -l compile-broken.el
It causes messed version compilation.
Side note: On attempt to quit (C-x C-c) I get
org-clock-kill-emacs-query: Symbol’s function definition is void:
org-clocking-buffer
and I had to use `kill-emacs' at this point. Exit hooks should not be so
aggressive.
Next session demonstrates the issue:
emacs -Q -L ~/src/org-mode/lisp/ -l org
There is a way to get Org completely broken. Let's simulate pulling of
bundled org through some dependency and configuring new directory
afterwards:
emacs -Q -l org --eval "(add-to-list 'load-path
\"~/src/org-mode/lisp/\")" /tmp/test.org
Version mismatch is not detected, but RET causes
eval-buffer: Symbol’s function definition is void: org-assert-version
I have no idea how to fight with such cases.
If you still can not reproduce with Emacs <= 28.1 then I may only
suggest to check (locate-library "org-macs") and to remind about
(list-load-path-shadows). I have no other ideas besides your environment
is not clean and development Org version is available to Emacs.
On 28/12/2022 16:46, Ihor Radchenko wrote:
Max Nikulin writes:
Notice that `org-assert-version' works for compiled files only.
I think that most reliable approach in this situation would be pulling
`org-assert-version' into a dedicated new file, similar to what you
suggested below. That way, we will not have feature cashes.
I considered it before and discarded at first since when an Org version
having such file is loaded then old version is used in the case of
messed version compilation. As a result, modification of
`org-assert-version' is ignored in the compiled version.
I reconsidered my opinion, though I still can not get really robust
problem detection. Emacs-27.1 and its built-in Org version is assumed below.
Since `org-assert-version' has effect in compiled files only, we need
some file with minimal dependencies that certainly will be compiled. It
might be org-assert-version.el itself. However then it be required
always rather than wrapped into `eval-when-compile' and should have
(org-assert-version) call inside.
However, I am concerned about what is going to happen if wrong
org-version is defined during compilation. `org-assert-version' can
then be compiled with wrong org-version value and later produce similar
obscure error.
If an old Org version is not loaded then the warning appears, so the
assertion works. A couple of issues:
- it does not suggest messed version compilation (reinstalling or
removing *.elc files and recompiling)
- due to long text just last paragraph about straight may be visible to
the user. Perhaps it is better to expand
https://orgmode.org/worg/org-faq.html#mixed-install and use a more
concise message with this link.
I have tried the following:
- move `org-assert-version' definition to org-assert-version.el, add
(org-assert-version) call to this file to have at least one file compiled.
- add (require 'org-assert-version) before (org-assert-version) to other
files.
The warning appears unless built-in Org is loaded before adding new
version to `load-path'. So we may proceed this way.
Some details concerning compilation errors in the case of Emacs-27.1 and
Org main:
- org.el is compiled (to my surprise)
- most of libraries not loaded before compilation, e.g. all ox-*.el
files fails.
The reason is that they require org-elemnt that requires org-persist.
The latter fails to call `org-file-name-concat' (that is missed in
loaded org-compat) and breaks creation of the .elc file.
Finally, there is a way to not have org-assert-version.el loaded during
regular sessions. Most of elisp files should have
(eval-when-compile (require 'org-assert-version))
(org-assert-version)
It should ensure latest `org-assert-version' definition during
installing of a new Org version. The issue is that compilation of
arbitrary file may fail and I am unsure if it is reasonable to introduce
another file to ensure compiled variant and to require it everywehere
(eval-when-compile (require 'org-assert-version))
(org-assert-version)
(require 'org-assert-version-call)
with org-assert-version-call.el
(eval-when-compile (require 'org-assert-version))
(org-assert-version)
(provide 'org-assert-version-call)