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

From: Ihor Radchenko <[email-masked]>
Date: Tue, 04 Jul 2023 12:20:25 +0000

Max Nikulin <[email-masked]> writes:

>> Do you know how to do it? Our previous reproducers involved M-x
>> package-install, but I am not sure how to test it without ELPA release.
>
> I have not tried yet, but I hope, preparing a tar file and using 
> `package-install-file' should behave in the same way as installing from 
> ELPA. Some spacemacs users believe they have noticed some difference, 
> but I am not convinced.

I tried this and indeed it revealed issues...

With

(defmacro org-require-with-shadowcheck (feature)
  "Load FEATURE making sure that it is loaded using current `load-path'.
When FEATURE is not yet loaded, act like `require' does.  When FEATURE
is loaded, but not consistent with the current value of `load-path',
re-load it."
  `(eval-and-compile
     (if (not (featurep ,feature)) (require ,feature)
       (let ((file (locate-library (symbol-name ,feature))))
         (unless (equal (feature-file ,feature) file)
	   ;; The feature is already provided, but from some other file
	   ;; than expected.  Presumably because `load-path` has been
	   ;; changed since the file was loaded.  This is likely a sign
	   ;; that we're loading a mix of files from different versions.
	   ;; That can spell trouble.
           (load file nil t t))))))

using https://git.sr.ht/~yantar92/org-mode/tree/feature/shadowcheck

1. emacs-30 -Q
2. M-x org-version
3. M-x package-install-file <RET> /path/to/org/lisp

I am getting

ob-C.el:40:2: Error: Eager macro-expansion failure: (error "Eager macro-expansion skipped due to cycle:
  … => (load \"org-element.el\") => (macroexpand-all (org-require-with-shadowcheck 'org …)) => (macroexpand (org-require-with-shadowcheck …)) => (load \"org.el\") => (load \"org-element.el\")")

which is rather curious since org.el is not supposed to load
org-element.el

I feel that I am missing something obvious.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>