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

From: Stefan Monnier <[email-masked]>
Date: Sun, 30 Apr 2023 21:48:50 -0400

>> BTW, have you tried to use a test along the lines of: look through
>> `load-history` to see if we loaded org-* files from a different directory
>> than the one in which `load-file-name` resides?
>
> Yup. Several problems here:
> 1. Not all the org-* files are a part of Org.

Ah right, we can't just match "org-*", indeed.

Maybe if we can identify a "first org-*.el file" (i.e. a file which
*any* use of some part of Org mode would necessarily load pretty early
on), then we can reduce this check to:

- check if that "first org-*.el file" is already loaded.
- if no, load it
- if yes, compare the output of `locate-file` to what is found in
  `load-history`, and in case it doesn't match (because of a new
  directory in `load-path`), signal an error (or maybe force a reload
  instead?).

We could even provide a new `require-with-shadow-check` function that
does just that.

        Stefan