Fork me on GitHub
#cider
<
2020-04-07
>
solf03:04:58

So far the workaround seems to do the job, but then again I could have sweared it also worked at first without the workaround

vemv14:04:31

https://docs.cider.mx/cider/usage/misc_features.html#_reloading_code says: cider-ns-refresh wraps clojure.tools.namespace, While https://github.com/clojure-emacs/cider/blob/f4eebe621231f088afb47cd93884444bfd1f0473/cider-ns.el#L192 says: does not rely on org.clojure/tools.namespace. So I'm wondering - what's the exact relationship between cider and t.n?

vemv14:04:39

For extra context, I reload code my own way (without cider's helpers), which works OK, but I need to understand how most emacsers do this

bozhidar14:04:08

@vemv The fancier refresh command uses c.t.n., the basic reload command just does :reload.

vemv14:04:21

Got it, thanks for the explanation.

bozhidar14:04:38

It really depends on what you need (and whether you’re working with Clojure or ClojureScript).

mikerod15:04:48

If I add this:

:plugins [[cider/cider-nrepl "0.25.0-SNAPSHOT"]]
to my project and do a lein repl I keep getting errors like:
Unable to resolve var: cider.nrepl/wrap-apropos in this context
and warnings etc.

mikerod15:04:06

I’ve tried with 0.24.0 and see the same - not even trying to connect cider, just start the repl

mikerod15:04:25

I see only 2019 issues looking like this - so don’t seem to be still around - but do I need to add more dependencies?

mikerod16:04:22

Narrowed it down slightly: I cannot find a way to start a cider-nrepl loaded repl on a lein plugin project

mikerod16:04:29

including leiningen’s project itself

mikerod16:04:42

I’ve tried bumping the nrepl to 0.7.0 there, but doesn’t fix it

mikerod16:04:10

I get this sort of error each time. I’ve tried with cider-jack-in-clj using latest cider, but also I’ve tried starting the lein repl myself with the cider-nrepl (0.24.0 and 0.25.0-SNAPSHOT behave the same for me) explicitly given.

mikerod16:04:53

Where

[nREPL] Starting server via /usr/local/bin/lein update-in :dependencies conj \[nrepl\ \"0.7.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.0-SNAPSHOT\"\] -- repl :headless :host localhost
is what my version of cider-jack-in-clj is doing cider-version = CIDER 0.25.0snapshot (package: 20200404.914)

dpsutton16:04:49

what's your lein version @mikerod

dpsutton16:04:10

this sounds like an older nrepl maybe? 0.5.6 instead of 0.6 or now 0.7

dpsutton16:04:05

and i see you tried bumping it but maybe check some lein deps :tree and lein deps :plugin-tree to see what nrepl version is actually resolved?

mikerod16:04:26

@dpsutton the lein version I have in this was 2.8.3 - so maybe that’s the cause

mikerod16:04:43

but wonder why this only happens when trying to start a repl with cider-repl middleware in a plugin

mikerod16:04:05

as in :eval-in :leiningen has to be in the project.clj that I’m working on

mikerod16:04:11

for the problem to occur

mikerod16:04:16

confuses me quite a bit

dpsutton16:04:15

been a bit but i think that lein 2.8.3 is nrepl < 0.6 which would explain the failure on nrepl.middleware.print. Why that happens only as a plugin I haven't a clue, unless maybe as a proper dep it affects the dep version resolution better?

dpsutton16:04:27

ie, if a proper dep it gets to override lein's nrepl version. as a plugin it doesn't?

mikerod16:04:08

so when you try to load a “plugin project” I guess it puts your current lein version deps on the same classpath

mikerod16:04:14

so that’s probably where we get this mismatch

mikerod16:04:58

so perhaps newer cider now requires newer nrepl - and I can’t have old lein running things in these projects

mikerod16:04:05

because it means 2.8.3 lein is trying to share classpath with these newer cider deps and they clash on nrepl

mikerod16:04:49

this sounds plausible. I will tryin a few to bump my lein version to see if it it clears it up

mikerod17:04:56

> ie, if a proper dep it gets to override lein’s nrepl version. as a plugin it doesn’t? yes, probably the issue indeed

bozhidar17:04:50

@mikerod When using cider-jack-in CIDER will override the nREPL bundled with Lein, but I think if you just use cider-nrepl as a plugin you’ll end up using whatever nREPL is shipped with Lein.

bozhidar17:04:07

Probably that’s causing the problem.

mikerod17:04:22

I bumped my actual local lein version and I can now start repls in plugin projects

mikerod17:04:29

So yes, the take away is that if you have :eval-in :leiningen in your project.clj (it’s a plugin project), then your lein version has to be compatible with cider deps since they are all on same classpath

dpsutton17:04:30

2.9.3 is current?

mikerod17:04:32

can’t override

mikerod17:04:40

2.9.3 is current yeah

dpsutton17:04:04

i suppose a new one will come soon depending on nrepl 0.7.0

mikerod17:04:49

when I was using 2.8.3 I was getting [nrepl "0.5.3"] on my classpath I think

mikerod17:04:02

which was too far below the min threshold for recent cider middleware I’d think - so was getting the missing var stuff

dpsutton17:04:18

@bozhidar thanks for your work on this stuff! its so important for the community at large

mikerod17:04:37

thanks to both of you for talking through this here - problem solved

bozhidar17:04:57

@dpsutton You’re welcome! :man-bowing:

bozhidar17:04:29

> i suppose a new one will come soon depending on nrepl 0.7.0 I’ve been planning to send a PR about this for a week now. I’ll do it soon.

🎉 4
bozhidar17:04:53

I doubt there’ll be a new Lein release soon, as Phil just cut the latest one, so I’m taking my time. 🙂

em19:04:31

Really beginner question here, but how do I send the entire code buffer to the REPL? My separate-window REPL throws errors about undefined symbols even after cider-load-buffer, but evaluation inside the code buffer (with C-c C-c , C-c C-e for example) works fine. This works perfectly fine for me but makes the separate repl buffer kinda useless. For context, I'm on a fresh install of Doom Emacs using their packaged defaults; not sure if that's the issue. Couldn't find anything inside the documentation about a command like cider-load-buffer-in-repl

dpsutton19:04:56

Sounds like namespace fundamentals. You evaluated a buffer that puts functions into a namespace. Then in the repl (by default in the user namespace) you reference a function defined in a different ns

em20:04:53

@dpsutton Whoops, you're absolutely right, just assumed that the repl would ns to my current file for some reason, even though now I think about it it'd be kinda hard/not make sense across multiple buffers. Thanks a ton for the sanity check!

dpsutton20:04:41

yeah. when you eval things in the buffer it looks to see that ns. you're in charge of the ns in your repl

Trey21:04:38

is there is cider-inspector type thing for elisp values?

aisamu13:04:30

Aha, found it! It's darn simple but it worked last time I tried: https://www.emacswiki.org/emacs/DataDebug

Trey21:04:35

Nice! I threw together a usable (for me) setup:

(use-package emacs-lisp-mode
  :ensure nil
  :bind (("C-c M-i" . elisp-inspect))
  :config
  (defun elisp-inspect ()
    (interactive)
    (data-debug-eval-expression (elisp--preceding-sexp))))

aisamu13:04:30

Aha, found it! It's darn simple but it worked last time I tried: https://www.emacswiki.org/emacs/DataDebug