Argh.. lost a good half-hour trying to chase down a bug in all the wrong places ā turns out Cider's debugger prints map entries in an extremely misleading way, making me think I had a misplaced concat somewhere
CIDER is not doing anything wrong here. You're converting the map using š
seq. CIDER prints exactly the data structure you asked for
Nope, expected output is ([:a 1] [:b 2])
that's not what seq on a map does
Ah
Sorry š
weird
the inspector does this too - try cider-inspect on
(list (vec {:a 1 :b 2}))this smells like it could be a MapEntry thing
Yeah definitely, tracking it down now
This must be related to the recent changes in internal CIDER printing logic. I will take a look
Yep, the orchard.print/print multifn on :map-entry
@alexyakushev I see you were the author of those changes, alright to leave the fixes to you without opening an issue?
I believe inspector was always like that. Not sure why.
An issue would still be appreciated for posterity. I'll get to the fix
that's strange, surely someone else would've noticed it before
The inspector rendering code was not used in the debugger before. And in the inspector, I guess you don't often inspect sequences of mapentries.
I see, this behavior was used to print a map like a sequence of mapentries so that it looks like a regular printed map.
Here's my workaround for now, until I regain my trust in the debugger actually helping me to debug things :P
(require 'orchard.print)
(remove-all-methods orchard.print/print)
(defmethod orchard.print/print :default
[x w] (print-method x w))
This will change the look of the inspector too, but sure, whatever works
Now I'm getting all sorts of TruncatingStringWriter$TotalLimitExceeded errors trying to debug a large nested value :/
I think these hardcoded values in cider-nrepl are the cause:
https://github.com/clojure-emacs/cider-nrepl/blob/af0d1e0e2351293019fc95ec8b9c8822c51ac6c9/src/cider/nrepl/middleware/debug.clj#L185
I'm not so familiar with Java writers, but it appears to be throwing to signal a non-local exit instead of an unexpected error? Seems like there's a missing try-catch wrapper somewhere
(binding [orchard.print/*max-total-length* 10]
(orchard.print/print-str :longer-than-ten-chars))
;; => Execution error (TruncatingStringWriter$TotalLimitExceeded) at mx.cider.orchard.TruncatingStringWriter/write (TruncatingStringWriter.java:87).
;; nullAh, my bad - I'm on an older version of cider-nrepl / orchard, I see it's been fixed on the current release
Fix is live in cider-nrepl 0.50.1
I started a long-running task in a CIDER Clojure REPL which was opened using M-x cider-connect. I lost my connection to the Clojure process. I can re-connect, but the new connection has a separate output stream, so Iām not seeing the output from the earlier REPL session. Is there any way to redirect that output to the new, open REPL?
https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/out.clj performs bindings and alter-var-roots.
Say that the 'old' code was running
(while true (println 1))
...for that case, I'd say that no matter what we do, that code will always be looking that the old binding of *out* which would point to the stale writer.Probably reusing 'dead repls' (there's a defcustom for that) would result in old output and new output gathered under the same Emacs buffer, but it doesn't fix the behavior I described. I'd look instead at using file-backed logging, for example.
We also have cider-log-mode which certainly survives reconections :)
It's worth checking if this is related to the recent nrepl changes, just in case. Can you achieve a small reproducible that demonstrates this behavior?