emacs-lsp / lsp-treemacs

lsp-mode :heart: treemacs
GNU General Public License v3.0
403 stars 48 forks source link

Void variable 'treemacs--project-positions' used when running dap #138

Closed moritzschaefer closed 2 years ago

moritzschaefer commented 2 years ago

When I try to debug a python script (via debugpy), I get the following error at the cross-section of treemacs and lsp-treemacs:

Debugger entered--Lisp error: (void-variable treemacs--project-positions)
  treemacs-GENERIC-extension()
  lsp-treemacs-initialize()
  lsp-treemacs-render(((:label #("☐ Raised Exceptions" 0 1 ... 1 19 ...) :key "raised" :filter "raised" :icon icon :session #s(dap--debug-session :name "Python :: Run file (buffer..." :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser ... :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads ... :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args ... :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil) :default nil :ret-action dap-ui-breakpoints-toggle) (:label #("☑ Uncaught Exceptions" 0 1 ... 1 21 ...) :key "uncaught" :filter "uncaught" :icon icon :session #s(dap--debug-session :name "Python :: Run file (buffer..." :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser ... :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads ... :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args ... :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil) :default t :ret-action dap-ui-breakpoints-toggle) (:label #("☐ User Uncaught Exceptions" 0 1 ... 1 26 ...) :key "userUnhandled" :filter "userUnhandled" :icon icon :session #s(dap--debug-session :name "Python :: Run file (buffer..." :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser ... :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads ... :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args ... :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil) :default nil :ret-action dap-ui-breakpoints-toggle) (:key #("main_qm9.py:2 e3_diffusion..." 0 14 ... 14 41 ... 41 43 ... 43 45 ...) :icon dap-breakpoint :icon-literal #("⬤ " 0 2 ...) :label #("main_qm9.py:2 e3_diffusion..." 0 14 ... 14 41 ... 41 43 ... 43 45 ...) :actions (... ... ... "--" ...) :file-name "/home/moritz/Projects/e3_d..." :point 48 :ret-action dap-ui-breakpoints-goto-breakpoint :breakpoint (:point 48 :marker #<marker at 48 in main_qm9.py>))) " Breakpoints " nil "*dap-ui-breakpoints*" (["Refresh" dap-ui-breakpoints]))
  dap-ui-breakpoints--refresh()
  dap-ui-breakpoints()
  #f(compiled-function (feature-start-stop) #<bytecode 0x16e8961c4d74e12>)(breakpoints)
  mapc(#f(compiled-function (feature-start-stop) #<bytecode 0x16e8961c4d74e12>) (sessions locals breakpoints expressions controls tooltip))
  seq-do(#f(compiled-function (feature-start-stop) #<bytecode 0x16e8961c4d74e12>) (sessions locals breakpoints expressions controls tooltip))
  dap-ui--show-many-windows(#s(dap--debug-session :name "Python :: Run file (buffer)<1>" :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads (#<hash-table equal 2/65 0x5cbeb4b>) :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args (:type "python" :request "launch" :name "Python :: Run file (buffer)<1>" :program "/home/moritz/Projects/e3_diffusion_for_molecules/m..." :args [] :dap-server-path ("/run/current-system/sw/bin/python" "-m" "debugpy.adapter")) :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil))
  run-hook-with-args(dap-ui--show-many-windows #s(dap--debug-session :name "Python :: Run file (buffer)<1>" :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads (#<hash-table equal 2/65 0x5cbeb4b>) :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args (:type "python" :request "launch" :name "Python :: Run file (buffer)<1>" :program "/home/moritz/Projects/e3_diffusion_for_molecules/m..." :args [] :dap-server-path ("/run/current-system/sw/bin/python" "-m" "debugpy.adapter")) :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil))
  dap--select-thread-id(#s(dap--debug-session :name "Python :: Run file (buffer)<1>" :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads (#<hash-table equal 2/65 0x5cbeb4b>) :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args (:type "python" :request "launch" :name "Python :: Run file (buffer)<1>" :program "/home/moritz/Projects/e3_diffusion_for_molecules/m..." :args [] :dap-server-path ("/run/current-system/sw/bin/python" "-m" "debugpy.adapter")) :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil) 1)
  dap--on-event(#s(dap--debug-session :name "Python :: Run file (buffer)<1>" :last-id 6 :proc #<process Python :: Run file (buffer)<1>> :response-handlers #<hash-table eql 0/65 0x6d7d2c7> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer #<buffer *Python :: Run file (buffer)<1> out*> :thread-id 1 :workspace nil :threads (#<hash-table equal 2/65 0x5cbeb4b>) :thread-states #<hash-table eql 1/65 0x71a7d57> :active-frame-id nil :active-frame nil :cursor-marker nil :state running :breakpoints #<hash-table equal 1/65 0x77fe1b5> :thread-stack-frames #<hash-table eql 0/65 0x77fe3e3> :launch-args (:type "python" :request "launch" :name "Python :: Run file (buffer)<1>" :program "/home/moritz/Projects/e3_diffusion_for_molecules/m..." :args [] :dap-server-path ("/run/current-system/sw/bin/python" "-m" "debugpy.adapter")) :local-to-remote-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b854a7d1057f>) :remote-to-local-path-fn #f(compiled-function (&rest args2) #<bytecode -0xae2b8549705057f>) :current-capabilities #<hash-table equal 20/65 0x2d4ff63> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x2d4ff83> :output-displayed nil) #<hash-table equal 4/65 0x8337027>)
  #f(compiled-function (m) #<bytecode -0xb1bd4d76c13211f>)("{\"seq\": 12, \"type\": \"event\", \"event\": \"stopped\", \"...")
  mapc(#f(compiled-function (m) #<bytecode -0xb1bd4d76c13211f>) ("{\"seq\": 12, \"type\": \"event\", \"event\": \"stopped\", \"..."))
  #f(compiled-function (_ msg) #<bytecode -0x12218a5f97b0f36e>)(#<process Python :: Run file (buffer)<1>> "Content-Length: 152\15\n\15\n{\"seq\": 12, \"type\": \"event\"...")

The treemacs--project-positions variable recently got kickek out of treemacs (https://github.com/Alexander-Miller/treemacs/commit/e815ab296e86da383d10ea5566b759557936a150) so it is somewhat expected that it is undefined. However, I am unable to find where that variable is even erroneously used. When following the backtrace to the top-most function, I get to the lsp-treemacs.el file, to the following function:

(treemacs-define-variadic-node generic
  :query-function lsp-treemacs-tree
  :render-action
  (treemacs-render-node
   :icon (lsp-treemacs--generic-icon item nil)
   :label-form (plist-get item :label)
   :state treemacs-node-closed-state
   :key-form (plist-get item :key)
   :more-properties (:item item))
  :root-key-form 'LSP-Generic)

When searching for the variable name (treemacs-project-positions), I don't get any hits in all of my el files.

Let me know if I can provide any additional debug output.

Version: lsp-treemacs 20220918.742 available melpa LSP treemacs

yyoncho commented 2 years ago

This should be fixed in latest lsp-treemacs. (Make sure to upgrade treemacs as well)

moritzschaefer commented 2 years ago

Thank you for the response @yyoncho. Both treemacs and lsp-treemacs are up to date.

Is there a way to clean potentially interferring old .elc files? Do you have other ideas how old code might lead to this?

yyoncho commented 2 years ago

@moritzschaefer so if you upgrade lsp-treemacs and then upgrade treemacs you will end up like this.

yyoncho commented 2 years ago

The solution is to delete both packages, restart emacs and install them.