Fork me on GitHub
Joshua Suskalo00:06:55

@bozhidar you have any suggestions for my problem, where I'd like to prevent a value which implements IDeref from being derefed when it's pretty printed as a return value in cider?


I can look in a bit but I’m guessing it’s an extend method we added to the print mechanism. Should be overridqble back and that is a bug in my view


Hmm. This sounds weirder and weirder. Since derefing can trigger blocking and on delays can trigger computation prematurely.

Joshua Suskalo01:06:25

Yeah, I also implement IBlockingDeref and that impl isn't used ever

Joshua Suskalo01:06:11

The problem is I'm trying to implement custom promises in order to prevent a breaking change to my api, but I don't want to have to require my users have cider or nrepl on their classpath to run the application, but I also don't want it to hang if they try something out on the repl


Yeah agreed


Hopefully there’s a way to fix up in code without waiting on a release


(def ^:dynamic pretty-objects "If true, cider prettifies some object descriptions. For instance, instead of printing functions as #object[clojure.core$PLUS 0x4e648e99 \"clojure.core$PLUS@4e648e99\"] they are printed as #function[clojure.core/+] To disable this feature, do (alter-var-root #'cider.nrepl.print-method/pretty-objects not)" true)


You can turn it off with that dynamic var. can probably easily redef the print-method for ideref in your repl and that should be removed I think


@suskeyhose i'm looking into this some more. I see that the printer for the c.l.IDeref checks to see if a) its also IPending and b) if so, if its realized. ( Is it possible for you to also add IPending to your custom promise types such that the printer works better? I still think this is a bug in cider-nrepl but this also might allow you to add a bit more onto your type to make it a bit better as well


I'm actually less convinced this is a bug. in a bare clj repl:

~/p/d/cider-nrepl ❯❯❯ clj
Clojure 1.10.1
user=> (reify clojure.lang.IDeref (deref [_] (do (prn "i'm gonna sleep a while") (Thread/sleep 3000) :slept/value)))
"i'm gonna sleep a while"
#object[user$eval136$reify__137 0x29182679 {:status :ready, :val :slept/value}]
just printing the reify will cause it to deref. the printer side-effects that. You need to add the IPending instead


Seems I’m late to this conversation and you’ve made plenty of progress without me. Might be a good idea to move this to some issue, so that the important points won’t get lost with the Slack history.


cross post alert! posted in #clojurescript, too...


to try the code at I created the project with

lein new figwheel cljs-weather -- --reagent
added the code and dependencies, and then ran
then opened the project in emacs, where I ran
and the project opened in my browser. I can evaluate simple forms in core.cljs like (+ 1 1) with cider-eval-defun-at-point but trying to evaluate the ns form or, trying to get data from the web with (GET <some url>) causes me to get
Caused by java.lang.RuntimeException
   Unable to resolve symbol: GET in this context
so, what do I have to do to be able to evaluate forms in my buffer as with clj in a cljs project?


@patrickanium I guess you forgot to load the buffer first (`C-c C-k`) and your requires are not in scope.

Jim Newton13:06:17

I've defined a record named Foo with a print-method and in the cider repl, it seems to ignore my print-method . Is that normal? My emacs value of cider-print-fn is pprint and I have not set this value anywhere. Its the value out-of-the-box as far as I know.

Jim Newton13:06:07

At the moment I don't know if it is a Clojure bug, or a cider but, or a Jim bug.

Jim Newton13:06:54

clojure-rte.core> (defrecord Foo [x])
clojure-rte.core> (map->Foo {:x 100})
{:x 100}
clojure-rte.core> (defmethod print-method 'Foo [v w]  (.write w (format "#<Foo x=%s>" (:x v))))
#multifn[print-method 0x7665aecc]
{:x 100}
clojure-rte.core> (pprint (map->Foo {:x 100}))
{:x 100}
clojure-rte.core> (print (map->Foo {:x 100}))
#<Foo x=100>nil


If you do these steps in a simple “clj” repl is the behavior the same?

Jim Newton14:06:20

you mean cli from the shell command line?

Jim Newton14:06:51

from the clj repl it seems to work.

user=> (defrecord Foo [x])
user=> (defrecord Foo [x])
user=> (defmethod print-method 'Foo [v w]  (.write w (format "#<Foo x=%s>" (:x v))))
user=> (defmethod print-method 'Foo [v w]  (.write w (format "#<Foo x=%s>" (:x v))))
#object[clojure.lang.MultiFn 0x61e3cf4d "[email protected]"]
user=> (map->Foo {:x 100})
user=> (map->Foo {:x 100})
#user.Foo{:x 100}

Jim Newton14:06:20

if I change the emacs variable

(setq cider-repl-use-pretty-printing nil)
then the repl prints using my print-method ... this seems to indicate a bug in the cider-pprint-fn implementation, that it neglects to take print-method into account. right?


Ah nevermind, it was my own user.clj causing the issue... But anyway, CIDER is still broken with the most recent shadow-cljs ("missing instance")


See Best you can do is to downgrade shadow for now.


Oh... thanks!


that has nothing to do with missing instance.


missing instance means shadow-cljs is not started in the process you are connected to. so maybe just connected to wrong nrepl server?


I did a jack-in, not a connect. Seems like it is the issue that's also open about cider not working when shadow uses deps.clj for dependencies.


this just means you need to start shadow-cljs before using it ...


(require 'shadow.cljs.devtools.server) (shadow.cljs.devtools.server/start!)


no clue if cider is supposed to do that on its own at some point or what jack-in does exactly


Yes, jack-in is supposed to start the nrepl server, be that via CLI tools, Leiningen, Boot, or Shadow.


nrepl server yes but that has nothing to do with shadow-cljs


but I don't know anything about cider ... I'm just telling you that if you get a missing instance then the shadow-cljs server is not started. whether it is your job to start it or ciders I don't know.

David Pham03:06:16

@bozhidar can we have a flag to remove clj-suitable while it is not working with shadow-CLJS?


This will require a new release of CIDER and cider-nrepl, as we’ll need to dynamically load clj-suitable for this to work. There’s already a flag that disables suitable even today, but the current problem happens at load time and the flag doesn’t help with it.


I can look into this later today or tomorrow if there’s no fix for suitable by then.

Joshua Suskalo14:06:58

@dpsutton Thanks for the tip! Just implementing a basic implementation of IPending fixes the issue.

cider 4

Hi all, lein 2.9.3 depends on nREPL 0.6.0 ( and the most recent version of cider-nrepl v0.25.2 depends on nREPL 0.7.0 ( ... how I can deal with this conflict if my project.clj defines :pedantic? :abort ?


You’re at the right place. 🙂


@bozhidar how do I get the requires in scope?


I loaded the buffer with C-c C-k but it errors on the first form (the ns one with the require).


whoa... just changed to clojurescript-mode (M-x clojurescript-mode) and it works!


thanks for the help 🙂