Hey cider folks, do you guys have these needs like me? What’s your solutions?
I typically start my CLJ repl through the terminal and have my shadow build started in a .clj file. Then I use cider-connect and cider-connect-sibling-cljs. That's probably redundant and there may be a one and done command but not sure. Either way this works for me.
Thanks, Ben! I just figured out the solution for the first problem: define (cider-shadow-watched-builds . (":primary-build" ":build2")in .dir-locals.el in the project dir root, following this doc section: https://docs.cider.mx/cider/cljs/shadow-cljs.html#using-cider-jack-in-cljs
I still can't wrap my head around M-x cider-jack-in-clj&cljs. Both clj and cljs works alone, below is a comparison and the problem description for clj&cljs.
1. M-x cider-jack-in-clj works if I just wanted to bring up clj repl alone.
Though I don't know why it let me choose from clojure-cli and shadow-cljs, and I go for clojure-cli as I use dpes.edn.
Isn't shadow-cljs only for cljs build? Why is it a candidate for clj?
2. M-x cider-jack-in-cljs also works.
First I select shadow and then select build target, no problem at all.
3. M-x cider-jack-in-clj&cljs doesn't work.
First, I select clojure-cli just like I do with M-x cider-jack-in-clj. Then select shadow for cljs and its build target.
1. Cider complained that error in process filter: cider-verify-clojurescript-is-present: ClojureScript is not available. See , and I haven't found anything interesting following the link.
2. I can eval things in .clj buffers, which means the clj repl works perfectly?
3. For .cljs buffers, there is no repl associated, so it's impossible to eval things.
4. Here is the info in the cljs repl buffer:
;; Startup: /home/ken/local/bin/clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.3.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.50.3\"\}\ cider/piggieback\ \{\:mvn/version\ \"0.5.3\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[cider.nrepl/cider-middleware\,cider.piggieback/wrap-cljs-repl\]\"\]\}\}\} -M:cider/nrepl
;;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :webapp) (shadow/watch :chrome-ext) (shadow/nrepl-select :webapp))
5. And the info in the clj one:
;; Startup: /home/ken/local/bin/clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.3.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.50.3\"\}\ cider/piggieback\ \{\:mvn/version\ \"0.5.3\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[cider.nrepl/cider-middleware\,cider.piggieback/wrap-cljs-repl\]\"\]\}\}\} -M:cider/nrepl
;;
;; ClojureScript REPL type: shadow
Is there something I'm missing? Thanks.Your CLJS repl is tied to the runtime you're targeting. If that's the browser you need to have your watched build open in the browser so that shadow can connect to it. Once that's done, you can jack in (or connect) and eval CLJS code
Yeah, I'm aware of that. If I do cider-jack-in-cljs alone, I can eval code after opening my browser. It seems like the targets are not watched yet from the repl buffer info.
I use this workflow pretty much https://code.thheller.com/blog/shadow-cljs/2024/10/18/fullstack-cljs-workflow-with-shadow-cljs.html
If the problem persists, feel free to create a minimal project with the jvm part and two cljs builds I have https://github.com/reducecombine/icd.scroll as a minimal project - cider-connect-clj&cljs and cider-jack-in-clj&cljs are documented in the readme
Did you know there's cider-connect-clj&cljs ? It should result in an overall simpler approach - as @bhlieberman93 suggests, creating all processes from the CLI is most debuggable
Thanks, I’m reading it now.
Thanks for the tips, I’ll run the nrepl from the command line and connect to it, and see how it goes. If I can’t figure it out at last, I’ll create a minimal project when it’s possible.
OMG it's way too complicated to make cider-jack-in-clj&cljs to work. In theory, I think it should work aftter setting :deps true in shadow-cljs.edn. The good news is that, I just found I can just start two nREPLs separately with cider-jack-in-clj and cider-jack-in-cljs, who needs cider-jack-in-clj&cljs 🙂 Anyway, maybe I'll come back to this issue when I have more time at hand in the future.
Happy New Year, my friends!
Happy new year, fellow cats! 😸
Hi all, I'm having a little trouble getting cider to work with deps.edn and cider-connect.
This is the relevant part of my deps.edn:
:aliases
{:dev {:extra-paths ["dev"]
:extra-deps {integrant/repl {:mvn/version "0.4.0"}}}
:cider/nrepl
{:extra-deps {cider/cider-nrepl {:mvn/version "0.50.3"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.10.0"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]}
I start the repl with
clj -M:dev -M:cider/nrepl
But when doing cider-connect I get the following warning:
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!
I cannot recreate that issue.
❯ clj -M:dev -M:cider/nrepl
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-M:cider/nrepl (No such file or directory)
Full report at:
/var/folders/1d/3ns5s1gs7xjgb09bh1yb6wpc0000gn/T/clojure-4869337155175857287.ednwhat if you do clj -M:dev:cider/nrepl?
things work fine for me then
❯ clj -M:dev:cider/nrepl
Downloading: cider/cider-nrepl/0.50.3/cider-nrepl-0.50.3.pom from clojars
Downloading: cider/orchard/0.28.0/orchard-0.28.0.pom from clojars
Downloading: cider/orchard/0.28.0/orchard-0.28.0.jar from clojars
Downloading: cider/cider-nrepl/0.50.3/cider-nrepl-0.50.3.jar from clojars
nREPL server started on port 58223 on host localhost - What does emacs say when you cider-connect to it?
Make sure you also include an explicit nrepl/nrepl {:mvn/version "1.3.0"} dependency too. The wrong version is currently pulled transitively.
ha. i was wondering about that and figured cider/nrepl would depend on one that worked for it
honestly surprised cider.nrepl doesn’t have a convenient entrypoint that always includes it’s middleware configured for you
In fact it does, it's just that the version pulled by cider/nrepl is currently a bit outdated. It should work except for a few features.
I'm still getting the warning even with both suggestions 😞
i’m a bit confused. When you used separate -M:dev -M:cider/nrepl did it not error? That’s strange to me.
Do (run! println (.split (System/getProperty "java.class.path") ":")) at the REPL.
@alexyakushev sending you the output in private
It's only to check if cider-nrepl and refactor-nrepl JARs are on the classpath. You can look for it yourself, don't worry sending me anything sensitive.
OK, I can see they are on the classpath. So, the aliases work as intended.
Could it be that you have some outdated REPLs running in the background, and you accidentally connect to one of the them? Check with jcmd in the terminal and kill all the processes first, then try again..
let me restart emacs
Close all Java/Clojure processes too
It seems like a minor thing, but i think it could be important.
When I run clj -M:dev -M:cider/nrepl it errors and fails to start. I think @alexyakushev’s question here is a good one. I’d check the file that contains the port and make sure you are connecting to the correct nrepl instance
tbh, I'm not sure if -M flags are additive and not just overwrite one another
the latter is treated as std input to the process i believe
The joy of Unix shell 🥴
`:clojure.main/message
"Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\n-M:cider/nrepl (No such file or directory)\n",
:clojure.main/triage
{:clojure.error/class java.io.FileNotFoundException,
:clojure.error/line -2,
:clojure.error/cause "-M:cider/nrepl (No such file or directory)",
:clojure.error/symbol java.io.FileInputStream/open0,
:clojure.error/source "FileInputStream.java",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.io.FileNotFoundException,
:message "-M:cider/nrepl (No such file or directory)",
:at [java.io.FileInputStream open0 "FileInputStream.java" -2]}],
:traceExplicit parentheses would save it oparen oparen oparen cparen cparen cparen
I changed the cmd to clj -M:dev:cider/nrepl
Also, I killed all java processes and restarted emacs, still getting the warning :s It's like the middleware is not being passed to nrepl somehow. I'm double checking the :main-opts
Yeah, good point, --middleware is likely next on the list to blame.
Are you sure your clj is an original Clojure CLI script and not some shell alias with extras?
i think that’s on purpose? Here’s what cider wants to use t ojack in for me
/opt/homebrew/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.27.4"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
which seems the samewhich clj
> i think that’s on purpose? I meant it looks correct but middleware not applying is most likely the issue now.
to answer your question, i am able to cider-connect to the instance with no warnings printed for me
❯ which clj
/opt/homebrew/bin/cljPlease try clojure instead of clj
@pablore can you answer a question for me? Can you run the command you originally ran clj -M:dev -M:cider/nrepl and tell me the exact output?
The original cmd was a typo in slack, @dpsutton. Sorry for the confusion, I had always been using -M:dev:cider/nrepl
@alexyakushev same
However, nREPL starts for you, so :main-opts is surely considered. But it appears there is a problem with middleware.
Can you try removing refactor-nrepl middleware from the vector, leaving only cider.nrepl/cider-middleware?
Got a new warning this time:
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information)
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 3.11.3 and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.does cider-connect inject more dependencies that I don't know about? I thought only cider-jack-in did that
Nah, it doesn't.
cider connect cannot inject dependencies. it is just connecting to a running instance that has already started up
Let's step back for a second – can you cider-jack-in into the same project and not receive the warnings?
Ah! cider-jack-in throws the same warning! Now I'm thinking this could be a emacs configuration problem
Yeah. I would suggest updating CIDER to the latest version, and then comment out the customizations until you get it working.
perhaps the warning is erroneous. one thing to check is if the middleware are present regardless of the warning. if you do something like cider-apropos and check for union or something, do you get an error about an unhandled operation or do you get a nice popup with all the functions that have union in their name?
Or just , classpath at the REPL should tell you that the middleware is alive.
both cider-apropos and , classpath work fine!
so perhaps this was nothing?
Could be. Still peculiar what has fried CIDER's brain like that. I would wipe the cider directory from ~/.emacs.d/elpa/ and install it again just in case.