emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Autoload `org-assert-version' and remove org-loaddefs.el


From: Kyle Meyer
Subject: Re: [PATCH] Autoload `org-assert-version' and remove org-loaddefs.el
Date: Fri, 02 Dec 2022 23:18:44 -0500

Bastien writes:

> Kyle Meyer <kyle@kyleam.com> writes:
[...]

>> Every spot that calls org-assert-version is preceded by a line that
>> requires org-macs, so isn't this error likely due to a mixed
>> installation/load-path issue where the wrong/older org-macs is taking
>> precedence?
>
> Yes: I thought `org-assert-version' job was to help catching mixed
> installations, so my reasoning was that, even when an old org-macs
> version has been loaded, autoloading `org-assert-version' would help
> report about mixed installation.

I see.  So your goal isn't to resolve any errors due to mixed
installation but instead to get the more informative error message from
org-assert-version?

I don't think autoloading will help because it will look in the
org-macs file at the front of the load-path, and, in the bad case, that
does not have the org-assert-version definition.

Here's a minimal example:

--8<---------------cut here---------------start------------->8---
#!/bin/sh

set -eu

tdir=$(mktemp -d "${TMPDIR:-/tmp}"/autoload-shadow-test-XXXXXXX)
cd "$tdir"

mkdir a
cat<<'EOF' >a/foo.el
(defun foo-do ()
  (message "foo"))

(provide 'foo)
EOF

mkdir b
echo "(provide 'foo)" >b/foo.el

cat<<'EOF' >test.el
(add-to-list 'load-path
             (concat default-directory (file-name-as-directory "a")))
(add-to-list 'load-path
             (concat default-directory (file-name-as-directory "b")))

(autoload 'foo-do "foo")
(foo-do)
EOF

emacs -Q --batch --load=test.el
--8<---------------cut here---------------end--------------->8---

If I run that, I see:

  Debugger entered--Lisp error: (error "Autoloading file 
/tmp/autoload-shadow-test-gmlO35u...")
    (foo-do)
    load-with-code-conversion("/tmp/autoload-shadow-test-gmlO35u/test.el" 
"/tmp/autoload-shadow-test-gmlO35u/test.el" nil t)
    command-line-1(("--load=test.el"))
    command-line()
    normal-top-level()

And commenting out the add-to-list call for b confirms that it works
without the shadowing.

> That said, do you have any idea how to fix the bug people encounter
> when installing Org from ELPA and being bitten by "invalid-function
> org-assert-version"?

Sorry, I don't.  Given a mixed installation where the org-macs at the
front of load-path does _not_ have org-assert-version, I don't see a way
to catch that.  Not helpful at the moment, but I suppose the situation
improves with time as Org versions that do not have org-assert-version
become less abundant.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]