svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
501 stars 34 forks source link

Invalid slot name for dape-connection :events-buffer-config #170

Closed simonsjw closed 2 weeks ago

simonsjw commented 2 weeks ago

Error:

Invalid slot name: "#<dape-connection dape-connection-18d46d72ccac>", :events-buffer-config

software: Emacs 29.4 Python 3.9.17 debugpy 1.8.7

Install:

(use-package dape :straight (:type git :host github :repo "svaante/dape" :files ("*" (:exclude ".git")))

:config ;; Turn on global bindings for setting breakpoints with mouse (dape-breakpoint-global-mode) ;; Timeout is 30 seconds. (setq dape-request-timeout 30) ;; Info buffers to the right (setq dape-buffer-window-arrangement 'right) ;; Projectile users (setq dape-cwd-fn 'projectile-project-root) )

Template: debugpy (default install)

I'm happy to provide any additional detail needed.

svaante commented 2 weeks ago

Hey, see the following issue https://github.com/svaante/dape/issues/95. Your package manager failed to update jsonrpc to its required version >= 1.0.25

simonsjw commented 2 weeks ago

Updating jsonrpc fixed the issue. Out of interest, even after using straight to get the latest jsonrpc and rebuilding/compiling, the package continued to source an original jsonrpc provided with the emacs source files. The solution was to manually update that file and then recompile emacs. Seemed excessive but it worked. Thanks for the quick and useful response.

adonig commented 5 days ago

Is there a way to get this working without having to patch and recompile Emacs? I'm using the 29.4 package on Fedora and am happy with its stability. I initially thought the issue was with straight.el, but it appears to have installed the correct version of jsonrpc. For some reason, dape doesn’t seem to pick it up properly.

Here’s the relevant snippet from my init.el file:

(use-package jsonrpc
  :straight t
  :demand t)
(use-package dape
  :straight (dape :type git :host github :repo "svaante/dape")
  :after jsonrpc
  :init
  (require 'jsonrpc)
  (message "Load path for jsonrpc: %s" (locate-library "jsonrpc")))

In the *Messages* buffer, I see the following output:

Cloning dape...done
Building dape...done
Load path for jsonrpc: /home/asd/.emacs.d/straight/build/jsonrpc/jsonrpc.elc

This confirms that straight.el is installing and loading the correct jsonrpc version.

However, when I start a debugging session with dape, I encounter the following error:

slot-missing: Invalid slot name: "#<dape-connection dape-connection-f26ba4e>", :events-buffer-config

It seems like dape is still referencing the built-in jsonrpc version, despite the correct one being loaded. Is there a workaround to make dape pick up the updated jsonrpc without needing to patch and recompile Emacs?

adonig commented 4 days ago

I forked dape and inserted a line that prints the load path for jsonrpc. Then I installed dape from the fork:

(use-package jsonrpc
  :straight t
  :demand t)
(use-package dape
  :straight (dape :type git :host github :repo "adonig/dape")
  :after jsonrpc)

I deleted the .emacs.d folder and put the configs back and when I started emacs again it installed dape and printed:

Load path for jsonrpc: /home/asd/.emacs.d/straight/build/jsonrpc/jsonrpc.elc

So I checked whether that file mentions the slot :events-buffer-config and it does:

asd@fwk:~$ grep "events-buffer-config" /home/asd/.emacs.d/straight/build/jsonrpc/jsonrpc.elc
grep: /home/asd/.emacs.d/straight/build/jsonrpc/jsonrpc.elc: binary file matches

jsonrpc 1.0.16 that comes with Emacs 29.4 doesn't, so this has to be the bytecode file corresponding to the jsonrpc 1.0.25 elisp file that is located next to it:

asd@fwk:~$ grep "1.0.25" /home/asd/.emacs.d/straight/build/jsonrpc/jsonrpc.el
;; Version: 1.0.25

I have no idea what causes the error when running dape but it seems not to be the jsonrpc version.

adonig commented 4 days ago

The issue seems to be that earlier in my init.el I had this eglot config:

(use-package eglot
  :straight (:type built-in)
  :init (setq eglot-connect-timeout 120)  
  :config
  (add-to-list 'eglot-server-programs '(elixir-ts-mode . ("elixir-ls")))
  (add-to-list 'eglot-server-programs '(python-ts-mode . ("pyright-langserver" "--stdio"))))

(use-package eglot-booster
  :straight (:type git :host github :repo "jdtsmith/eglot-booster")
  :after eglot
  :config (eglot-booster-mode))

The eglot version that comes with Emacs 29.4 (:type built-in) uses jsonrpc 1.0.16.

Now dape requires eglot after jsonrpc:

(require 'jsonrpc)
(require 'eglot) ;; jdtls config

(message "Load path for jsonrpc: %s" (locate-library "jsonrpc"))

And this seems to cause an issue somehow giving us the old jsonrpc version in dape because when I remove the :straight (:type built-in) so it installs a newer version of eglot the issue is gone.

adonig commented 4 days ago

The solution to all of this is making sure that jsonrpc gets installed before eglot and before dape:

(use-package jsonrpc
  :straight t)

(use-package eglot
  :straight (:type built-in)
  :after jsonrpc
  :init (setq eglot-connect-timeout 120)  
  :config
  (add-to-list 'eglot-server-programs '(elixir-ts-mode . ("elixir-ls")))
  (add-to-list 'eglot-server-programs '(python-ts-mode . ("pyright-langserver" "--stdio"))))

(use-package dape
  :straight t
  :after jsonrpc)

I believe once Emacs 30 is stable, this is not going to be an issue anymore because it comes with jsonrpc >= 1.0.25

EDIT: You can even omit installing jsonrpc altogether by just using the most recent version of eglot.

(use-package eglot :straight t)
(use-package dape :straight t)