cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
bozhidar 2021-02-18T08:17:34.346Z

There's a cider-connected-hook.

bozhidar 2021-02-18T08:18:12.346200Z

There's also cider-repl-init-code.

bozhidar 2021-02-18T08:18:56.346400Z

(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"))

danielneal 2021-02-18T12:44:20.346800Z

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

jumar 2021-02-19T10:53:06.360600Z

Is there a way to β€œdebug” such debugger issues πŸ˜€?

2021-02-23T11:28:48.010900Z

I stopped using the debugger years ago because the debugger was so temperamental debugging http requests.

jumar 2021-02-24T09:45:29.019200Z

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...

jumar 2021-02-24T09:48:10.021100Z

@danieleneal you're right! It would be worth to report this - I'd love to see this fixed.

2021-02-24T09:49:56.021400Z

@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.

jumar 2021-02-24T09:50:05.021600Z

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

jumar 2021-02-24T09:53:16.021900Z

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?

danielneal 2021-02-24T09:53:57.022200Z

Yeah, c works for me

danielneal 2021-02-24T09:59:34.022400Z

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.

πŸ‘ 1
jumar 2021-02-24T10:05:42.022700Z

Another thing that seems to mess up the debugger state is t (trace)

danielneal 2021-02-24T11:59:20.022900Z

Raised https://github.com/clojure-emacs/cider-nrepl/issues/689

πŸ‘ 1
bozhidar 2021-02-25T08:32:35.023900Z

> Is there a way to β€œdebug” such debugger issues

bozhidar 2021-02-25T08:33:05.024100Z

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.

bozhidar 2021-02-25T08:35:00.024300Z

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).

bozhidar 2021-02-25T08:36:23.024600Z

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

bozhidar 2021-02-25T08:36:35.024800Z

(it's simpler than most people would think it is)

jumar 2021-02-26T11:02:20.037500Z

Cool, thanks for sharing! I'll have a look next week if this is something I could do.

jumar 2021-02-18T14:03:24.347Z

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.

danielneal 2021-02-18T14:42:57.347200Z

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?

jumar 2021-02-18T14:44:39.347400Z

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

danielneal 2021-02-18T14:49:22.347600Z

Do I need extra middleware apart from cider.nrepl/cider-middleware?

jumar 2021-02-18T14:49:46.347800Z

No, I don't think so.

danielneal 2021-02-18T14:54:06.348Z

thanks, I'll keep at it

danielneal 2021-02-18T14:58:43.348200Z

oh, it's working

danielneal 2021-02-18T14:58:50.348400Z

restarting the repl worked

jumar 2021-02-18T15:00:47.348600Z

Yeah, that's a PITA. I don't know why it sometimes happen but I hit this issue every now and then.

danielneal 2021-02-18T15:34:27.348800Z

thanks for your help πŸ™‚

Eamonn Sullivan 2021-02-18T21:06:49.351800Z

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...

dpsutton 2021-02-18T21:08:35.352500Z

did you add the test alias when jacking in?

Eamonn Sullivan 2021-02-18T21:08:55.352900Z

Ah, do I have to do that? How do I do that?

dpsutton 2021-02-18T21:09:19.353500Z

easiest way, hit C-u before jacking in and add a -A:test right after the bin/.../clojure part

Eamonn Sullivan 2021-02-18T21:10:21.354200Z

Right, thanks! I've gone this long without ever needing a test-only dependency...

dpsutton 2021-02-18T21:12:18.355100Z

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

πŸ‘€ 1
Eamonn Sullivan 2021-02-18T21:14:12.356400Z

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!

2021-02-18T21:15:18.356500Z

Anything one should look at beside (cider-clojure-cli-global-options . "-M:test") ?

dpsutton 2021-02-18T21:17:05.356700Z

i think that's correct. there was a little bit of flux and a clojure-cli-aliases or something like that recently

dpsutton 2021-02-18T21:17:26.356900Z

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)

2021-02-18T21:20:09.357100Z

ah, I see -- good to know!