GNU bug report logs -
#78392
31.0.50; eglot breaks on xref-find-definitions
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 78392 in the body.
You can then email your comments to 78392 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78392
; Package
emacs
.
(Mon, 12 May 2025 14:48:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"admin <at> sonictk.com" <admin <at> sonictk.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 12 May 2025 14:48:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Currently, when building from latest Emacs ToT, activating `eglot-mode`
in any C++ file using `clangd` and attempting to call
`xref-find-definitions` on any definition results in the following error
being triggered:
```
Opening input file: Is a directory, c:/Users/sonictk/tmp
```
Where the `.cpp` file is in the given directory. Tried building Emacs
using a build from a month-ish ago to find where the regression first
occurred and it still had the issue present, even when doing `make
distclean` and then `make bootstrap` after re-running `./configure`.
`toggle-debug-on-error` gives me:
```
Debugger entered--Lisp error: (file-error "Opening input file" "Is a directory" "c:/Users/sonictk/tmp")
eglot--xref-make-match(#("Baz" 0 3 (face font-lock-function-name-face fontified t)) "file:///c:/Users/sonictk/tmp/test2.cpp" (:end (:character 11 :line 23) :start (:character 8 :line 23)))
#f(compiled-function (loc-or-loc-link) #<bytecode 0x413eb090fd3d661>)((:range (:end (:character 11 :line 23) :start (:character 8 :line 23)) :uri "file:///c:/Users/sonictk/tmp/test2.cpp"))
eglot--lsp-xrefs-for-method(:textDocument/definition)
#f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>)(eglot "LSP identifier at point")
apply(#f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>) eglot "LSP identifier at point")
xref-backend-definitions(eglot "LSP identifier at point")
#f(compiled-function () #<bytecode 0x558a9dc3551d156>)()
xref-show-definitions-buffer(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) ((window . #<window 9 on test2.cpp>) (display-action) (auto-jump)))
xref--show-defs(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) nil)
xref--find-definitions("LSP identifier at point" nil)
xref-find-definitions("LSP identifier at point")
funcall-interactively(xref-find-definitions "LSP identifier at point")
command-execute(xref-find-definitions)
```
In GNU Emacs 31.0.50 (build 1, x86_64-w64-mingw32) of 2025-05-11 built
on CDW-AQRHE1HHT39
Repository revision: 64eb60bd91dbeed458d5a410e6dc9ab4e9e0a10e
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.5737)
Configured using:
'configure --without-pop --with-imagemagick --without-compress-install
-without-dbus --with-gnutls --with-json --with-tree-sitter
--without-gconf --with-rsvg --without-gsettings --with-mailutils
--with-native-compilation --with-modules --with-xml2 --with-wide-int
'CFLAGS=-O3 -ggdb -fno-math-errno -funsafe-math-optimizations
-fno-finite-math-only -fno-trapping-math -freciprocal-math
-fno-rounding-math -fno-signaling-nans -fassociative-math
-fno-signed-zeros -frename-registers -funroll-loops -mtune=native
-march=native -fomit-frame-pointer -fallow-store-data-races
-fno-semantic-interposition -floop-parallelize-all
-ftree-parallelize-loops=4'
PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'
Configured features:
ACL GIF GMP GNUTLS HARFBUZZ IMAGEMAGICK JPEG LCMS2 LIBXML2 MODULES
NATIVE_COMP NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB
Important settings:
value of $LC_CTYPE: en_US.UTF-8
value of $LANG: ENU
locale-coding-system: cp1252
Major mode: C++//l
Minor modes in effect:
eglot-inlay-hints-mode: t
eglot--managed-mode: t
flymake-mode: t
tooltip-mode: t
global-eldoc-mode: t
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
minibuffer-regexp-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
abbrev-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils time-date cl-extra eglot tree-widget
wid-edit external-completion jsonrpc xref flymake thingatpt project diff
diff-mode track-changes easy-mmode ert pp ewoc debug backtrace help-mode
find-func filenotify warnings compile text-property-search comint
ansi-osc ansi-color ring pcase url-util url-parse auth-source cl-seq
eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt
gv url-vars imenu comp-run bytecomp byte-compile comp-common rx cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
touch-screen dos-w32 ls-lisp term/w32-nt disp-table term/w32-win w32-win
w32-vars term/common-win 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 nadvice seq simple cl-generic indonesian philippine
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 abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads w32notify w32 lcms2 multi-tty move-toolbar make-network-process
tty-child-frames native-compile emacs)
Memory information:
((conses 16 576487 112162) (symbols 48 13713 0)
(strings 32 43491 4466) (string-bytes 1 1432645) (vectors 16 51034)
(vector-slots 8 835660 10348) (floats 8 61 76) (intervals 56 678 13)
(buffers 1064 17))
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78392
; Package
emacs
.
(Mon, 12 May 2025 15:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78392 <at> debbugs.gnu.org (full text, mbox):
> From: "admin <at> sonictk.com" <admin <at> sonictk.com>
> Date: Mon, 12 May 2025 06:29:15 +0000
>
> Currently, when building from latest Emacs ToT, activating `eglot-mode`
> in any C++ file using `clangd` and attempting to call
> `xref-find-definitions` on any definition results in the following error
> being triggered:
>
> ```
> Opening input file: Is a directory, c:/Users/sonictk/tmp
> ```
>
> Where the `.cpp` file is in the given directory. Tried building Emacs
> using a build from a month-ish ago to find where the regression first
> occurred and it still had the issue present, even when doing `make
> distclean` and then `make bootstrap` after re-running `./configure`.
>
> `toggle-debug-on-error` gives me:
>
> ```
> Debugger entered--Lisp error: (file-error "Opening input file" "Is a directory" "c:/Users/sonictk/tmp")
> eglot--xref-make-match(#("Baz" 0 3 (face font-lock-function-name-face fontified t))
> "file:///c:/Users/sonictk/tmp/test2.cpp" (:end (:character 11 :line 23) :start (:character 8 :line 23)))
> #f(compiled-function (loc-or-loc-link) #<bytecode 0x413eb090fd3d661>)((:range (:end (:character 11 :line
> 23) :start (:character 8 :line 23)) :uri "file:///c:/Users/sonictk/tmp/test2.cpp"))
> eglot--lsp-xrefs-for-method(:textDocument/definition)
> #f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>)(eglot "LSP identifier at point")
> apply(#f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>) eglot "LSP identifier at
> point")
> xref-backend-definitions(eglot "LSP identifier at point")
> #f(compiled-function () #<bytecode 0x558a9dc3551d156>)()
> xref-show-definitions-buffer(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) ((window .
> #<window 9 on test2.cpp>) (display-action) (auto-jump)))
> xref--show-defs(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) nil)
> xref--find-definitions("LSP identifier at point" nil)
> xref-find-definitions("LSP identifier at point")
> funcall-interactively(xref-find-definitions "LSP identifier at point")
> command-execute(xref-find-definitions)
> ```
Thanks. Does the patch below give good results?
João, I think the assumption that 'retval' there necessarily starts
with a slash is because url-generic-parse-url would not necessarily
DTRT with Windows file:// URIs; it was fixed lately. So now we need
to test for that before applying the fixup.
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index eae8e1b..6f6b05a 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1165,7 +1165,8 @@ eglot-uri-to-path
;; Remove the leading "/" for local MS Windows-style paths.
(normalized (if (and (not remote-prefix)
(eq system-type 'windows-nt)
- (cl-plusp (length retval)))
+ (cl-plusp (length retval))
+ (eq (aref retval 0) ?/))
(w32-long-file-name (substring retval 1))
retval)))
(concat remote-prefix normalized))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78392
; Package
emacs
.
(Mon, 12 May 2025 17:57:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 78392 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
As an addendum, I tried downloading the latest provided Emacs Windows build from https://gnu.mirror.constant.com/emacs/windows/ , which reads as:
```
In GNU Emacs 30.1 (build 2, x86_64-w64-mingw32) of 2025-02-23 built on
AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.5737)
Configured using:
'configure --with-modules --without-dbus
--with-native-compilation=aot --without-compress-install
--with-tree-sitter CFLAGS=-O2 prefix=/g/rel/install/emacs-30.1'
```
And with no other configuration changes and with the same clangd, things work fine (opened the same test2.cpp and attempted to navigate to definition.) So this is most likely a regression, but I haven't been able to pin it down to a specific commit yet.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78392
; Package
emacs
.
(Mon, 12 May 2025 19:20:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 78392 <at> debbugs.gnu.org (full text, mbox):
> From: "admin <at> sonictk.com" <admin <at> sonictk.com>
> Date: Mon, 12 May 2025 14:52:13 +0000
>
> As an addendum, I tried downloading the latest provided Emacs Windows build from
> https://gnu.mirror.constant.com/emacs/windows/ , which reads as:
>
> ```
> In GNU Emacs 30.1 (build 2, x86_64-w64-mingw32) of 2025-02-23 built on
> AVALON
> Windowing system distributor 'Microsoft Corp.', version 10.0.19045
> System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.5737)
>
> Configured using:
> 'configure --with-modules --without-dbus
> --with-native-compilation=aot --without-compress-install
> --with-tree-sitter CFLAGS=-O2 prefix=/g/rel/install/emacs-30.1'
>
> ```
>
> And with no other configuration changes and with the same clangd, things work fine (opened the same
> test2.cpp and attempted to navigate to definition.) So this is most likely a regression, but I haven't been
> able to pin it down to a specific commit yet.
I believe it was the change in url-generic-parse-url, which now
produces correct Windows file names, without the extra leading slash.
IOW, when we fixed url-generic-parse-url, that fix exposed a subtle
bug in Eglot, because Eglot was trying to fix the bug in
url-generic-parse-url locally...
However, since Eglot is on ELPA and supports earlier Emacs versions,
that code should be left in Eglot, just under an additional condition
that the file name indeed starts with a slash.
Did you have an opportunity to test the patch I suggested with Emacs
31?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78392
; Package
emacs
.
(Mon, 12 May 2025 20:11:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 78392 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks. I think the patch makes sense. Free to push. If you can, please
prefix the first line of commit message with "Eglot: ", like the other ones
to this file.
João
On Mon, May 12, 2025, 20:57 admin <at> sonictk.com <admin <at> sonictk.com> wrote:
> Hi Eli:
>
> Thanks for responding. Confirmed that applying the patch locally solves
> the issue. Appreciate the help here!
>
>
> ------------------------------
> *From:* Eli Zaretskii <eliz <at> gnu.org>
> *Sent:* Monday, May 12, 2025 8:16 AM
> *To:* admin <at> sonictk.com <admin <at> sonictk.com>; João Távora <
> joaotavora <at> gmail.com>
> *Cc:* 78392 <at> debbugs.gnu.org <78392 <at> debbugs.gnu.org>
> *Subject:* Re: bug#78392: 31.0.50; eglot breaks on xref-find-definitions
>
> > From: "admin <at> sonictk.com" <admin <at> sonictk.com>
> > Date: Mon, 12 May 2025 06:29:15 +0000
> >
> > Currently, when building from latest Emacs ToT, activating `eglot-mode`
> > in any C++ file using `clangd` and attempting to call
> > `xref-find-definitions` on any definition results in the following error
> > being triggered:
> >
> > ```
> > Opening input file: Is a directory, c:/Users/sonictk/tmp
> > ```
> >
> > Where the `.cpp` file is in the given directory. Tried building Emacs
> > using a build from a month-ish ago to find where the regression first
> > occurred and it still had the issue present, even when doing `make
> > distclean` and then `make bootstrap` after re-running `./configure`.
> >
> > `toggle-debug-on-error` gives me:
> >
> > ```
> > Debugger entered--Lisp error: (file-error "Opening input file" "Is a
> directory" "c:/Users/sonictk/tmp")
> > eglot--xref-make-match(#("Baz" 0 3 (face font-lock-function-name-face
> fontified t))
> > "file:///c:/Users/sonictk/tmp/test2.cpp" (:end (:character 11 :line 23)
> :start (:character 8 :line 23)))
> > #f(compiled-function (loc-or-loc-link) #<bytecode
> 0x413eb090fd3d661>)((:range (:end (:character 11 :line
> > 23) :start (:character 8 :line 23)) :uri "
> file:///c:/Users/sonictk/tmp/test2.cpp"))
> > eglot--lsp-xrefs-for-method(:textDocument/definition)
> > #f(compiled-function (backend id) #<bytecode
> -0x10624bec505aa107>)(eglot "LSP identifier at point")
> > apply(#f(compiled-function (backend id) #<bytecode
> -0x10624bec505aa107>) eglot "LSP identifier at
> > point")
> > xref-backend-definitions(eglot "LSP identifier at point")
> > #f(compiled-function () #<bytecode 0x558a9dc3551d156>)()
> > xref-show-definitions-buffer(#f(compiled-function () #<bytecode
> 0x558a9dc3551d156>) ((window .
> > #<window 9 on test2.cpp>) (display-action) (auto-jump)))
> > xref--show-defs(#f(compiled-function () #<bytecode 0x558a9dc3551d156>)
> nil)
> > xref--find-definitions("LSP identifier at point" nil)
> > xref-find-definitions("LSP identifier at point")
> > funcall-interactively(xref-find-definitions "LSP identifier at point")
> > command-execute(xref-find-definitions)
> > ```
>
> Thanks. Does the patch below give good results?
>
> João, I think the assumption that 'retval' there necessarily starts
> with a slash is because url-generic-parse-url would not necessarily
> DTRT with Windows file:// URIs; it was fixed lately. So now we need
> to test for that before applying the fixup.
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index eae8e1b..6f6b05a 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -1165,7 +1165,8 @@ eglot-uri-to-path
> ;; Remove the leading "/" for local MS Windows-style paths.
> (normalized (if (and (not remote-prefix)
> (eq system-type 'windows-nt)
> - (cl-plusp (length retval)))
> + (cl-plusp (length retval))
> + (eq (aref retval 0) ?/))
> (w32-long-file-name (substring retval 1))
> retval)))
> (concat remote-prefix normalized))
>
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78392
; Package
emacs
.
(Tue, 13 May 2025 04:20:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78392 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Eli:
Thanks for responding. Confirmed that applying the patch locally solves the issue. Appreciate the help here!
________________________________
From: Eli Zaretskii <eliz <at> gnu.org>
Sent: Monday, May 12, 2025 8:16 AM
To: admin <at> sonictk.com <admin <at> sonictk.com>; João Távora <joaotavora <at> gmail.com>
Cc: 78392 <at> debbugs.gnu.org <78392 <at> debbugs.gnu.org>
Subject: Re: bug#78392: 31.0.50; eglot breaks on xref-find-definitions
> From: "admin <at> sonictk.com" <admin <at> sonictk.com>
> Date: Mon, 12 May 2025 06:29:15 +0000
>
> Currently, when building from latest Emacs ToT, activating `eglot-mode`
> in any C++ file using `clangd` and attempting to call
> `xref-find-definitions` on any definition results in the following error
> being triggered:
>
> ```
> Opening input file: Is a directory, c:/Users/sonictk/tmp
> ```
>
> Where the `.cpp` file is in the given directory. Tried building Emacs
> using a build from a month-ish ago to find where the regression first
> occurred and it still had the issue present, even when doing `make
> distclean` and then `make bootstrap` after re-running `./configure`.
>
> `toggle-debug-on-error` gives me:
>
> ```
> Debugger entered--Lisp error: (file-error "Opening input file" "Is a directory" "c:/Users/sonictk/tmp")
> eglot--xref-make-match(#("Baz" 0 3 (face font-lock-function-name-face fontified t))
> "file:///c:/Users/sonictk/tmp/test2.cpp" (:end (:character 11 :line 23) :start (:character 8 :line 23)))
> #f(compiled-function (loc-or-loc-link) #<bytecode 0x413eb090fd3d661>)((:range (:end (:character 11 :line
> 23) :start (:character 8 :line 23)) :uri "file:///c:/Users/sonictk/tmp/test2.cpp"))
> eglot--lsp-xrefs-for-method(:textDocument/definition)
> #f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>)(eglot "LSP identifier at point")
> apply(#f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>) eglot "LSP identifier at
> point")
> xref-backend-definitions(eglot "LSP identifier at point")
> #f(compiled-function () #<bytecode 0x558a9dc3551d156>)()
> xref-show-definitions-buffer(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) ((window .
> #<window 9 on test2.cpp>) (display-action) (auto-jump)))
> xref--show-defs(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) nil)
> xref--find-definitions("LSP identifier at point" nil)
> xref-find-definitions("LSP identifier at point")
> funcall-interactively(xref-find-definitions "LSP identifier at point")
> command-execute(xref-find-definitions)
> ```
Thanks. Does the patch below give good results?
João, I think the assumption that 'retval' there necessarily starts
with a slash is because url-generic-parse-url would not necessarily
DTRT with Windows file:// URIs; it was fixed lately. So now we need
to test for that before applying the fixup.
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index eae8e1b..6f6b05a 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1165,7 +1165,8 @@ eglot-uri-to-path
;; Remove the leading "/" for local MS Windows-style paths.
(normalized (if (and (not remote-prefix)
(eq system-type 'windows-nt)
- (cl-plusp (length retval)))
+ (cl-plusp (length retval))
+ (eq (aref retval 0) ?/))
(w32-long-file-name (substring retval 1))
retval)))
(concat remote-prefix normalized))
[Message part 2 (text/html, inline)]
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Tue, 13 May 2025 11:48:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"admin <at> sonictk.com" <admin <at> sonictk.com>
:
bug acknowledged by developer.
(Tue, 13 May 2025 11:48:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 78392-done <at> debbugs.gnu.org (full text, mbox):
> From: João Távora <joaotavora <at> gmail.com>
> Date: Mon, 12 May 2025 21:10:21 +0100
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 78392 <at> debbugs.gnu.org
>
> Thanks. I think the patch makes sense. Free to push. If you can, please prefix the first line of commit
> message with "Eglot: ", like the other ones to this file.
Thanks, done, and closing the bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 11 Jun 2025 11:24:14 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.