This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-23
Channels
- # announcements (3)
- # aws (1)
- # beginners (44)
- # biff (6)
- # calva (31)
- # cider (26)
- # clerk (12)
- # clj-kondo (9)
- # clojure (17)
- # clojure-dev (18)
- # clojure-europe (13)
- # clojure-norway (45)
- # clojure-uk (4)
- # clojurescript (34)
- # datomic (54)
- # dev-tooling (14)
- # emacs (19)
- # events (7)
- # honeysql (2)
- # hyperfiddle (51)
- # lsp (34)
- # malli (24)
- # matrix (1)
- # missionary (5)
- # off-topic (27)
- # re-frame (6)
- # reagent (18)
- # releases (2)
- # sci (6)
- # shadow-cljs (88)
- # vim (9)
When i connect to my shadow-cljs apps nrepl server using calva, I can eval expressions and see the output, when i do so in emacs (cider-connect-cljs), nothing happens. No errors in the message buffer. any advice would be welcome 🙂
Someone had a similar issue a few posts above, so I'll check if everything keeps working in a vanilla project following the official instructions
If you're talking about me, it works in the minibuffer but not in the cljs file (so it does connect properly). I think adding the dependencies as mentionned in the cider documentation in shadow-cljs.edn made cider connect work. But for me, I can't go in a cljs file and eval from there, it won't work for some reasons
In my case, it wasn't working with calva either. I mean, I was able to connect with cider to calva from vscodium, but still not able to eval from cljs file
Yeah I was talking about you. I'll try to investigate the issue you created.
Thanks for it wasn't working with calva either.
Please add that to the GH issue
@U0DJ4T5U1: I created https://github.com/reducecombine/shadow-cljs-cider-demo just now since I see reports like yours all the time in #cider sadly 😞
But the thing is it works! It's fairly simple/minimal, I followed cider/shadow-cljs doc and grabbed a bit from metabase's shadow-cljs.
It has a simple readme.
Note that I'm using cider-connect-cljs. connect*
variants tend to be easier to debug.
Thanks, I'll take a look. If i start the nrepl server from the command line, so i need to add any nrepl middle ware or deps to run cider jack in cljs?
I'll go check to see if that got removed... Hmmm
The issue, not being able to see the output of the evaling an expression, was fixed by using the shadow-cljs.edn middlware cider.nrepl/cider-middleware and refactor-nrepl.middlware/wrap-refactor. We had removed wrap-refactor at some point, but i thought it was working after that, maybe not. I think my confusion is understanding the full necessary set of deps and middlware to make shadow cljs and nrepl happy. Then understanding the ideal place to declare this. Ideally, unless someone wants to convince me otherwise, editor dependencies are up to the developer and so shouldn't make their way into the project. So that's a point against putting it in the shadow-cljs.edn. Though I'm happy to bend with the wind here, as long as my sails go in the right direction. ⛵ But it looks like the shadow docs imply nprel middleware can go in the ~/.nrepl/nrepl.edn. So i'll put it there. But where else can it go? I have a .clojure deps.edn that has an alias that i have been using for shadow projects for quite a while that injects the middleware
:cider-cljs
{:extra-deps {cider/cider-nrepl #:mvn{:version "RELEASE"},
cider/piggieback #:mvn{:version "RELEASE"},
nrepl/nrepl #:mvn{:version "RELEASE"},
refactor-nrepl/refactor-nrepl #:mvn{:version "RELEASE"}},
:main-opts
["-m" "nrepl.cmdline" "--middleware"
"[shadow.cljs.devtools.server.nrepl/middleware,refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}
are all those extra deps necessary? would it be possible to use this alias to launch my shadow client from the cli? THat's what i was doing before, that plus another alias :shadow-cljs
clj -M:cider-cljs:shadow-cljs run web3.build/watch -- staging
:shadow-cljs
{:main-opts ["-m" "shadow.cljs.devtools.cli"]}
can you even chain two main-opts values? like that?you can but only the last will be used, as per the docs.
> The issue, not being able to see the output of the evaling an expression, was fixed by using the shadow-cljs.edn middlware cider.nrepl/cider-middleware and refactor-nrepl.middlware/wrap-refactor. Nice! FWIW I don't think refactor-nrepl makes a difference. But the cider middleware is of course essential. You should get a warning when it's absent - did you not? (Yesteday I that experiment. I got the expected warning) The key part is: make sure cider-nrepl is in the classpath. Actually, shadow-cljs adds the cider middleware to the middleware stack if it can find it in the classpath
> are all those extra deps necessary?
piggieback is not, beyond any doubt.
I also would question nrepl/nrepl. shadow-cljs has its own repl server, so it has to depend on it
refactor-nrepl... only if you intend to use it (we're currently working on very nice ,cljc completions for cljr-slash
, btw)
For your scenario, it seems nice to create a :shadow-cider alias. Then users can opt in to activate it like this:
> You may also specify additional aliases via the command line using -A
, eg. shadow-cljs -A:foo:bar …
.
(copied verbatim from https://shadow-cljs.github.io/docs/UsersGuide.html)
The docs also talk about .nrepl.edn
, that seems the expected place to define project-specific middleware. You'd gitignore that for not affecting other users
> You should get a warning when it's absent - did you not? I got no error at the terminal or the messages buffer.
We were on a much older version of shadow, then we updated, i thought the repl was working after the update, but maybe not.
I think i'm confused about the role of the middleware, it seems like you have to have given some dependencies, but at the same time, i have to manage it but putting it in the nrepl.edn. What is the flexibility getting me? hmm it says shadow does add the nrepl middleware...
maybe that doesn't happen if you use deps. Maybe i should stop using deps for this project. i'm not sure its helping, this is the first time it's been an annoyance though.
> I got no error at the terminal or the messages buffer. It;s printed at the repl IIRC. I checked just yesterday
> I think i'm confused about the role of the middleware, it seems like you have to have given some dependencies, but at the same time, i have to manage it but putting it in the nrepl.edn. I have trouble parsing this
I got nothing in the repl either, but i'm not sure that's interesting. > I think i'm confused about the role of the middleware, it seems like you have to have given some dependencies, but at the same time, i have to manage it but putting it in the nrepl.edn. Sorry, that was poorly worded. Ill give an example or say nothing at all 🙂 My current headscratcher is this
clj -M:shadow-cljs-cider:shadow-cljs run web3.build/watch -- staging
[2023-06-26 14:27:30.298 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym cider.nrepl/cider-middleware}
FileNotFoundException Could not locate cider/nrepl__init.class, cider/nrepl.clj or cider/nrepl.cljc on classpath.
given this alias
:shadow-cljs-cider {:extra-deps {cider/cider-nrepl {:mvn/version "RELEASE"}
refactor-nrepl/refactor-nrepl {:mvn/version "RELEASE"}}}
^^ it seems i also have the middleware key and values in my shadow-cljs.edn.
:middleware [cider.nrepl/cider-middleware
refactor-nrepl.middleware/wrap-refactor]
headscratcher indeed. That enters into #shadow-cljs support territory. I've done all my testing using the shadow-cljs
npm executable
For emacs/cider purposes, I'd suggest using said executable and a minimal project (follow the official doc or clone https://github.com/reducecombine/shadow-cljs-cider-demo). That way you'll make sure it can work
Hope it helps!
thanks vemv.