Subject: bug#67696: 30.0.50; Help deal with multiple versions in load-path

From: Stefan Kangas <[email-masked]>
Date: Sat, 16 Dec 2023 11:07:23 -0800

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> With packages being available both as bundled with Emacs and as ELPA
> packages, it has become a lot more common place to have two versions of
> a package in the `load-path` and to have to deal with situations
> where the "incorrect" version has been loaded before `load-path`
> was changed.
>
> These kinds of problems manifest in various ways and we try to
> circumvent them in `package.el` in some cases but that can't cover
> all cases.
>
> I suggest we introduce a new function to help packages susceptible to
> those problems.  The patch below introduces a new function which
> I tentatively called `require-with-check` and shows how it could be used
> in the case of `eglot.el` (which relies on several core packages also
> distributed via GNU ELPA and currently uses a hack which slows it down
> unnecessarily in the normal case).

Will this be useful only for :core packages?  If so, it would be nice to
not have to introduce more functions and extra complexity just to deal
with this situation.  It seems like a problem we should be able to fix
without it leaking into our API.

I didn't think deeply about this so here's a probably naive question:
could we make `require' reload the file, if a newer one is detected
earlier in the load-path?

Are there any other alternative approaches that you considered?