Subject: bug#62762: 'make' often errors with "Org version mismatch" after pulling a new version of the code

From: Max Nikulin <[email-masked]>
Date: Sun, 7 May 2023 23:23:15 +0700

On 06/05/2023 20:02, Stefan Monnier wrote:
> AFAIU there are 2 main situations:
> 
> A) recompilation (i.e. `git pull; make`).
>     This can happen either in Org's repository or in Emacs's repository.
...
Are there brave enough developers and users who do not restart emacs 
after rebuild of emacs? Some Org users hope that `org-reload' works and 
they can update Org without restarting Emacs.

> B) mixed versions from different directories.
> 
> AFAICT `my-require-with-shadow-check` should be able to catch most/all
> problems for (B),

Agree.

> without impacting (A), and more reliably than
> `org-assert-version` (and in an arguably less ad-hoc way).

Sorry, but `org-assert-version' should catch loading from the same 
directory a file compiled for new version since loaded earlier 
org-version.el defined old version that does not match `org-version' 
inscribed into new .elc files. I assume either combination of "make 
clean" and "make" or proper incremental build. That is why I disagree 
with "without impacting (A)".

> So, to me, (assuming the above is true) the remaining question is what
> Org developers want to do about `git pull; make` in Org's own repository.

Perhaps `org-assert-directory' may be added to `org-assert-version'

By the way, if just org-macs should be checked then would not be it more 
efficient in respect to load time to define a variable containing the 
directory and to check in other files if they are loaded from the same 
directory? With such approach there is no need in walking through the 
`load-history' list.

==> tst-macs.el <==

(defun tst-get-load-dir ()
   (file-name-directory
    (or load-file-name
        ;; For `eval-buffer'.
        (buffer-file-name (buffer-base-buffer)))))

(defvar tst-load-dir (tst-get-load-dir))

(defun tst-assert-load-dir ()
   (let ((dir (tst-get-load-dir))
	(url "https://orgmode.org/worg/org-faq.html#mixed-install"))
     (unless (equal tst-load-dir dir)
       (error "Path shadowing detected, see <%s>. %s vs %s"
	     url dir tst-load-dir))))

(provide 'tst-macs)

==> tst-main.el <==

(require 'tst-macs)

(eval-and-compile
   (if (fboundp 'tst-assert-load-dir)
     (tst-assert-load-dir)
    (error "Path shadowing detected, see 
<https://orgmode.org/worg/org-faq.html#mixed-install>")))

(provide 'tst-main)