Fork me on GitHub
#cider
<
2022-01-17
>
gdanov18:01:46

Is cider supposed to evaluate depending namespaces? E.g. I have foo.core which contains protocols and foo.impl with implementations of the protocols. When I c-c c-k (eval buffer) in the foo.core buffer and re-run code in the REPL that uses foo.impl I get the type of exceptions that show foo.impl is stale and I need to re-evaluate it

vemv18:01:32

with cider-ns-refresh, which is a wrapper for tools.namespace or reload dependent namespaces by hand, some people swear by it

dpsutton18:01:43

can you explain a bit more of what you are doing? It sounds like you edited foo.impl, then reload foo.core and want to see the updated behavior of foo.impl? Is that correct?

gdanov18:01:57

@U45T93RA6 I don’t see how it’s supposed to solve my problem? plus, I’ve found it to mess up the repl if used too often

gdanov18:01:05

@U11BV7MTK let me fix my explanation: 1. with existing and evaluated foo.impl edit foo.core 2. eval foo.core 3. re-run code in repl 4. get error

No implementation of method: :apply-reaction of protocol:
   #'ffr.core/Reaction found for class: ffr.reactions.Targets

vemv18:01:18

so core contains a defprotocol, and impl defrecords? if you change core, save, then cider-ns-refresh, it will reload core and impl, preventing errors related to staleness

gdanov18:01:45

I need to save?

vemv18:01:52

not super sure with cider-ns-refresh, personally I use tools.namespace directly, which does

vemv18:01:44

my unknown is whether cider-ns-refresh saves, should be easy to check but it's certainly needed, because it uses this external lib called tools.namespace

gdanov19:01:41

ns-refresh does not do the job unfortunately, I get the same error

vemv19:01:14

generally it works but it can not work like 1% of the time, unless you take some explicit measures see also https://clojurians.slack.com/archives/C03S1KBA2/p1642439762134300?thread_ts=1642430221.125500&amp;cid=C03S1KBA2

gdanov19:01:23

I think metadata is looked up last, so this is the slowest performing option. I’d rather switch and re-eval, but thanks

vemv19:01:09

it's not looked up last, it's in the middle of the check chain

vemv19:01:54

also protocols generally represent IO work, so dispatch overhead will be negligible compared to said IO costs

peterdee19:01:44

Updating to cider-20220113.610 I found I was getting a version mismatch "WARNING: CIDER 1.3.0-snapshot requires cider-nrepl 0.28.0, but you're currently using cider-nrepl 0.27.4.". I got around it by (setq cider-jack-in-lein-plugins '(("cider/cider-nrepl" "0.28.0"))) which seems odd because the project where I started has a deps.edn and no project.clj.

vemv19:01:49

maybe you have cider-nrepl in your deps.edn which would need updating as well? but yeah IIRC there's some internal conflation between lein and deps.edn