Have you tried?

Save this as `package-reload.el' and run `emacs --batch -l package-reload.el':

(defadvice load (before debug)
  (message "(RE)LOADING %s" file))
(defadvice package--reload-previously-loaded (around debug activate)
  (ad-activate 'load)
  ad-do-it
  (ad-deactivate 'load))
;(require 'org)
(let ((temp (make-temp-file "packages" t)))
  (setf package-user-dir temp))
(require 'package)
(package-initialize)
(package-refresh-contents)
(package-install (cadr (assq 'org package-archive-contents)))

I get messages like "(RE)LOADING /tmp/packagesDLaBkh/org-9.6/org-macs". Doesn't matter if I uncomment that line with "(require 'org)" or not.

Paul



On Mon, 19 Dec 2022 at 00:48, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Add e.g. `(message "RELOAD %S" (car c))' before the `(load ...)' form in
> the function, reevaluate it and reinstall any package, e.g.:

When you re-install, the new files's names will be the same as the
previously loaded ones, so it's the corner case where it happens to work.

But if you start Emacs, load its builtin Org, and then install GNU
ELPA's Org, I doesn't seem to reload anything.


        Stefan