This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-09
Channels
- # babashka (63)
- # beginners (97)
- # biff (11)
- # chlorine-clover (5)
- # cider (46)
- # clara (2)
- # clj-kondo (34)
- # clojure (65)
- # clojure-austin (1)
- # clojure-europe (9)
- # clojure-france (10)
- # clojure-italy (11)
- # clojure-nl (3)
- # clojure-spec (29)
- # clojure-uk (5)
- # clojuredesign-podcast (1)
- # clojurescript (56)
- # clr (6)
- # component (17)
- # conjure (5)
- # core-typed (5)
- # cursive (23)
- # data-science (5)
- # datahike (3)
- # dirac (3)
- # emacs (20)
- # fulcro (17)
- # graalvm (10)
- # graphql (8)
- # helix (99)
- # honeysql (7)
- # jobs-discuss (9)
- # juxt (9)
- # leiningen (14)
- # malli (3)
- # meander (6)
- # off-topic (77)
- # pathom (7)
- # re-frame (12)
- # reagent (8)
- # reitit (10)
- # restql (1)
- # shadow-cljs (22)
- # spacemacs (10)
@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.
Yeah, I also implement IBlockingDeref and that impl isn't used ever
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
(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)
https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/print_method.clj
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. (https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_print.clj#L436-L457). 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}]
user=>
just printing the reify will cause it to deref. the printer side-effects that. You need to add the IPending
insteadSeems 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.
to try the code at https://www.learn-clojurescript.com/section-1/lesson-8-capstone-weather-forecasting-app/ I created the project with
lein new figwheel cljs-weather -- --reagent
added the code and dependencies, and then ran
yarn
then opened the project in emacs, where I ran
cider-jack-in-clj&cljs
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.
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.
At the moment I don't know if it is a Clojure bug, or a cider but, or a Jim bug.
clojure-rte.core> (defrecord Foo [x])
clojure_rte.core.Foo
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]
clojure-rte.core>
{:x 100}
clojure-rte.core> (pprint (map->Foo {:x 100}))
{:x 100}
nil
clojure-rte.core> (print (map->Foo {:x 100}))
#<Foo x=100>nil
you mean cli from the shell command line?
from the clj repl it seems to work.
user=> (defrecord Foo [x])
user=> (defrecord Foo [x])
user.Foo
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}
user=>
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 https://github.com/rksm/clj-suitable/issues/15 Best you can do is to downgrade shadow for now.
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.
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.
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.
@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.
@dpsutton Thanks for the tip! Just implementing a basic implementation of IPending fixes the issue.

Hi all, lein 2.9.3 depends on nREPL 0.6.0 (https://github.com/technomancy/leiningen/blob/2.9.3/project.clj#L21) and the most recent version of cider-nrepl v0.25.2 depends on nREPL 0.7.0 (https://github.com/clojure-emacs/cider-nrepl/blob/v0.25.2/project.clj#L7) ... how I can deal with this conflict if my project.clj
defines :pedantic? :abort
?
looking at https://docs.cider.mx/cider/caveats.html#injecting-dependencies-and-leiningen-pedantic-abort-mode