Subject: bug#61048: 28.2; Installing Eglot doesn't pull transitive Xref dependency

From: "Basil L. Contovounesios" <[email-masked]>
Date: Wed, 25 Jan 2023 00:20:27 +0000

Tags: patch

0. cd "$(mktemp -d)"
1. touch .dir-locals.el
2. HOME="${PWD}" XDG_CONFIG_HOME="${PWD}/.config" emacs-28.2
3. M-x toggle-debug-on-error RET
4. M-: (setq project-vc-extra-root-markers (list dir-locals-file)) RET
5. M-x package-install RET eglot RET
6. C-x p g Package-Requires RET

Debugger entered--Lisp error: (void-function xref-show-xrefs)
  xref-show-xrefs(#f(compiled-function (&rest args2) #<bytecode -0xac14b28472c08a0>) nil)
  project-find-regexp("Package-Requires")
  funcall-interactively(project-find-regexp "Package-Requires")
  call-interactively(project-find-regexp nil nil)
  command-execute(project-find-regexp)

Emacs 28 ships with Xref 1.3.0, and without Eglot.  Eglot depends on
Project 0.9.3 directly and on Xref 1.4.0 transitively.  Yet package.el
for some reason deems that the built-in Xref 1.3.0 satisfies this
requirement, and does not pull a more recent version from GNU ELPA.

[ BTW, there is nothing special about steps 1, 4, 6 in the recipe above:
  they just demonstrate that the expected version of Xref is missing. ]

At first glance this sounds like a package.el bug, but since there won't
be an Emacs 28.3, and until someone checks whether it's present in Emacs
29+, perhaps something like the following is needed as a workaround?

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 8ce1a8b7baf..8a85ccf7276 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -7,7 +7,7 @@
 ;; Maintainer: João Távora <[email-masked]>
 ;; URL: https://github.com/joaotavora/eglot
 ;; Keywords: convenience, languages
-;; Package-Requires: ((emacs "26.3") (jsonrpc "1.0.16") (flymake "1.2.1") (project "0.9.3") (xref "1.0.1") (eldoc "1.11.0") (seq "2.23") (external-completion "0.1"))
+;; Package-Requires: ((emacs "26.3") (jsonrpc "1.0.16") (flymake "1.2.1") (project "0.9.3") (xref "1.4.0") (eldoc "1.11.0") (seq "2.23") (external-completion "0.1"))
 
 ;; This is a GNU ELPA :core package.  Avoid adding functionality
 ;; that is not available in the version of Emacs recorded above or any

Thanks,

-- 
Basil

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2022-09-13 built on tia
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure 'CFLAGS=-O2 -march=native' --prefix=/home/blc/.local
 --program-suffix=-28.2 --with-file-notification=yes
 --with-x-toolkit=lucid --with-x'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Debugger

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
/tmp/tmp.wwpr6ZCm6G/.emacs.d/elpa/jsonrpc-1.0.16/jsonrpc hides /home/blc/.local/src/emacs-28.2/lisp/jsonrpc
/tmp/tmp.wwpr6ZCm6G/.emacs.d/elpa/project-0.9.5/project hides /home/blc/.local/src/emacs-28.2/lisp/progmodes/project

Features:
(shadow sort mail-extr emacsbug sendmail help-fns cl-print find-dired
vc-svn grep cl-extra easy-mmode external-completion array filenotify
jsonrpc xref flymake-proc flymake thingatpt project imenu ert ewoc debug
backtrace help-mode warnings pcase compile comint ansi-color ring
find-func autoload radix-tree lisp-mnt tar-mode arc-mode archive-mode
cus-edit pp wid-edit mm-archive message dired dired-loaddefs rfc822 mml
mml-sec epa derived gnus-util rmail rmail-loaddefs text-property-search
time-date mailabbrev gmm-utils mailheader mm-decode mm-bodies mm-encode
mail-utils gnutls network-stream url-http mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc puny url-cache
url-auth epg rfc6068 epg-config finder-inf package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
cus-start cus-load iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 150248 11680)
 (symbols 48 14395 1)
 (strings 32 52717 2277)
 (string-bytes 1 1443118)
 (vectors 16 24221)
 (vector-slots 8 304738 18582)
 (floats 8 50 144)
 (intervals 56 493 0)
 (buffers 992 17))