Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)

Home Page:https://conjure.fun

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clojure Debugger: Evaluation failing on debug reader tags

dradtke opened this issue · comments

I have a simple Hello World project initialized with Leiningen, and I'm unable to get Conjure to correctly handle the debugger reader tag.

Steps

  1. In one terminal pane, open a REPL with lein repl for Conjure to connect to.
  2. In another terminal pane, open a Clojure source file. Mine is simply:
(ns hello-world.core)

(defn add
  [x y]
  (+ x y))
  1. Initialize the debugger with :ConjureCljDebugInit
  2. Add a debugger reader tag to the add function right after the parameters list. (Tested with both #break and #dbg, since the wiki says to use the former, but the docs say to use the latter)
(defn add
  [x y]
  #dbg
  (+ x y))
  1. Evaluate the buffer with :ConjureEvalBuf

At this point I would expect the evaluation to have succeeded, but instead I get an error. See the results of my Conjure log below:

; Sponsored by @lucaslollobrigida ❤                                                                                                                                                                                                                  
; --------------------------------------------------------------------------------                                                                                                                                                                   
; localhost:38917 (connected): .nrepl-port                                                                                                                                                                                                           
; --------------------------------------------------------------------------------                                                                                                                                                                   
; Assumed session: Tonkinese cat (Clojure)                                                                                                                                                                                                           
; --------------------------------------------------------------------------------                                                                                                                                                                   
; Initialising CIDER debugger                                                                                                                                                                                                                        
; --------------------------------------------------------------------------------                                                                                                                                                                   
; CIDER debugger initialized                                                                                                                                                                                                                         
; --------------------------------------------------------------------------------                                                                                                                                                                   
; eval (buf): ...pace/hello-world/src/hello_world/core.clj                                                                                                                                                                                           
nil                                                                                                                                                                                                                                                  
; (err) Syntax error reading source at (REPL:6:10).                                                                                                                                                                                                  
; (err) No reader function for tag dbg

Tested with Conjure @ 4880144

Hmm I can't reproduce your issue, #dbg is always valid for me after the debugger is initialised, but it does look like the tag doesn't apply if I use <prefix>ef or <prefix>eb. I have to use <prefix>ee or <prefix>er to evaluate just that defn that contains the #dbg tag then everything works fine.

I don't see the error you're seeing, but it does look like the debugger doesn't kick in if I give it more than one form or a file to evaluate. Might have to check the nREPL + CIDER docs to check which circumstances the debugger applies in. Maybe it only works with single form evals in general?

Do you have the CIDER middleware installed? Because that's essential. If you just have a plain nREPL it won't work sadly, the debugger is part of CIDER. If this is the case then the initialisation should've failed and I'm surprised it didn't.

Would you be able to reproduce these steps but with let g:conjure#debug = v:true and share the full log output with me? Thanks a lot!

Good call on adding the CIDER middleware, I think that's what I was missing. I wonder if there's a way to detect that the middleware is missing and to show a more helpful error message.

For reference, here's my "hello world" project definition that I got this working with:

(defproject hello-world "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.11.1"]]
  :profiles {:repl {:dependencies [[nrepl/nrepl "1.1.0"]]
                    :plugins [[cider/cider-nrepl "0.45.0"]]}}
  :repl-options {:init-ns hello-world.core})

The Cider middleware installation docs were a little bit confusing since they're so Emacs-focused. In particular, missing the nrepl/nrepl dependency provides a very cryptic error that does not make it clear what is missing:

Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Error loading cider.nrepl: Syntax error macroexpanding at (cider/nrepl.clj:1:1).
Syntax error compiling var at (/tmp/form-init8220992668678554628.clj:1:9542).
Unable to resolve var: cider.nrepl/wrap-apropos in this context

Full report at:
/tmp/clojure-16324925140853946357.edn
Subprocess failed

Anyway, since I've solved my issue I'll go ahead and close it. Thanks!