Subject: Re: bug#67480: 30.0.50; Cannot start eglot

From: Stefan Monnier <[email-masked]>
Date: Tue, 28 Nov 2023 09:42:28 -0500

> Some of these files are preloaded, so I don't understand why you see
> these messages.  I suspect some problem with your build.

[ Note: This is unrelated to bug#67480.  ]

No, it's a problem in `eglot.el`:

    ;; These dependencies are also GNU ELPA core packages.  Because of
    ;; bug#62576, since there is a risk that M-x package-install, despite
    ;; having installed them, didn't correctly re-load them over the
    ;; built-in versions.
    (eval-and-compile
      (load "project")
      (load "eldoc")
      (load "seq")
      (load "flymake")
      (load "xref")
      (load "jsonrpc")
      (load "external-completion"))

I suspect this should be fixed the same way I proposed to fix these
kinds of problems in Org, i.e. with something like:

    (defun require-with-check (feature &optional filename noerror)
      "If FEATURE is not already loaded, load it from FILENAME.
    This is like `require' except if FEATURE is already a member of the list
    `features’, then we check if this was provided by a different file than the
    one that we would load now (presumably because `load-path' has been
    changed since the file was loaded)."
      (let ((lh load-history)
            (res (require feature filename noerror)))
        ;; If the `feature' was not yet provided, `require' just loaded the right
        ;; file, so we're done.
        (if (not (eq lh load-history)) res
          ;; If `require' did nothing, we need to make sure that was warranted.
          (let ((fn (locate-file (or filename (symbol-name feature))
                                 load-path (get-load-suffixes))))
            ;; If the right file was indeed loaded already, we're done.
            (if (assoc fn load-history) res
              (funcall (if noerror #'warn #'error)
                       "Feature provided by other file: %S" feature)
              res)))))

This sample code doesn't try to handle preloaded packages, so it
would/will need some tweak for that.

        Stefan