There's a cider-connected-hook
.
There's also cider-repl-init-code
.
(defvar cider-repl-require-repl-utils-code
'((clj . "(clojure.core/apply clojure.core/require clojure.main/repl-requires)")
(cljs . "(require '[cljs.repl :refer [apropos dir doc find-doc print-doc pst source]])")))
(defcustom cider-repl-init-code (list (cdr (assoc 'clj cider-repl-require-repl-utils-code)))
"Clojure code to evaluate when starting a REPL.
Will be evaluated with bindings for set!-able vars in place."
:type '(list string)
:group 'cider-repl
:package-version '(cider . "0.21.0"))
Is there a way of adding a breakpoint that will be hit when e.g. an http request is made, i.e. when a function is called indirectly rather than directly
Is there a way to βdebugβ such debugger issues π?
I stopped using the debugger years ago because the debugger was so temperamental debugging http requests.
Interesting observation - I didn't make a connection between these two things and I use q
every now and then.
I'll try to reproduce this in my project...
@danieleneal you're right! It would be worth to report this - I'd love to see this fixed.
@danieleneal IIRC now you mention it that sounds suspiciously similar to what I witnessed a few years back too β I thought Iβd reported it, but it was maybe just on the slack channel and not in a ticket.
It calls Thread's .stop
method which is known to cause problems - maybe that't the issue? https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/debug.clj#L143
Maybe a workaround is to press C
to skip all the breakpoints? https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/debug.clj#L364
... Oh no, that doesn't work either - so just c
?
Yeah, c
works for me
Interestingly, when debugging a function that is called indirectly via http, q
doesn't appear on the list of options, and when pressed breaks the debugger going forward. When debugging a function called directly, q
does appear on the list of functions, and when pressed, does not break the debugger.
Another thing that seems to mess up the debugger state is t
(trace)
Raised https://github.com/clojure-emacs/cider-nrepl/issues/689
> Is there a way to βdebugβ such debugger issues
Same as with all other issues - monitoring the message exchange, instrumenting thing on the Elisp side and playing with the Clojure part of the debugger in the REPL.
If someone wants to see this fixed any time soon they'll have to look into the problem themselves. As I've mentioned a few times - effectively no one but me is working on all the CIDER/nREPL related stuff these days, which means progress is slow and painful (if any).
This is the most detailed overview of the internals of the debugger for those interested - https://drive.google.com/file/d/1YhnPBJOXbUzXfVOEojICFTwhCt_3u6Ss/view?usp=sharing
(it's simpler than most people would think it is)
Cool, thanks for sharing! I'll have a look next week if this is something I could do.
There should be no difference and your "breakpoint" should be triggered. That said, I often times get into a state where no breakpoints are activated for some reason - restarting the REPL typically helps.
hmm interesting. Is there more to it than doing cider-debug-defun-at-point
in the function you want to debug, and then exercising the endpoint that calls the function?
I think that's it: Of course you can also use #dbg
which can be convenient if you have a larger function or if you want to break only on a specific condition: https://docs.cider.mx/cider/debugging/debugger.html#conditional-breakpoints
Do I need extra middleware apart from cider.nrepl/cider-middleware?
No, I don't think so.
thanks, I'll keep at it
oh, it's working
restarting the repl worked
Yeah, that's a PITA. I don't know why it sometimes happen but I hit this issue every now and then.
thanks for your help π
Am I doing something wrong here? I want to use an http mocking library in my tests, but I obviously don't need this in the production version of the library, so I added the dependency (clj-wiremock) like this:
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.2"}
clj-http/clj-http {:mvn/version "3.11.0"}
org.clojure/data.json {:mvn/version "1.0.0"}}
:aliases
{:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
kelveden/clj-wiremock {:mvn/version "1.5.7"}}}
but I can't eval the buffer on a test file in CIDER (C-c C-k). It does work if I move clj-wiremock
to the :deps
section. Is that right, or am I just missing something silly? I might be misunderstanding what the :test
alias is for...did you add the test alias when jacking in?
Ah, do I have to do that? How do I do that?
easiest way, hit C-u
before jacking in and add a -A:test
right after the bin/.../clojure
part
Right, thanks! I've gone this long without ever needing a test-only dependency...
no worries. if you update to the latest version of CIDER i can walk you through some dir-locals stuff to make sure you are always using the test alias so you never have to worry if you remembered to add it or not. it'll always be there when using CIDER
Thanks. I probably am using the latest (I use straight.el), but other half is yelling at me to get off the computer. Will look this up... And that did work, btw. Thank you again!
Anything one should look at beside (cider-clojure-cli-global-options . "-M:test")
?
i think that's correct. there was a little bit of flux and a clojure-cli-aliases
or something like that recently
still needs to be documented and its still missing a way to pass things at the end of the string to supply ports and such. ( i think)
ah, I see -- good to know!