cider

Ken Huang 2024-12-30T13:40:18.434919Z

Hey cider folks, do you guys have these needs like me? What’s your solutions?

liebs 2024-12-30T13:56:27.792819Z

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.

Ken Huang 2024-12-30T14:02:14.923029Z

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

Ken Huang 2024-12-30T15:11:12.246479Z

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 for details, 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.

liebs 2024-12-30T15:13:39.893289Z

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

Ken Huang 2024-12-30T15:17:38.760439Z

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.

vemv 2024-12-30T18:04:27.567709Z

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

vemv 2024-12-30T18:05:47.735669Z

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

Ken Huang 2024-12-30T21:16:22.716699Z

Thanks, I’m reading it now.

Ken Huang 2024-12-30T21:25:32.713649Z

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.

👍 1
Ken Huang 2024-12-31T16:03:11.745449Z

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!

vemv 2024-12-31T18:04:41.066929Z

Happy new year, fellow cats! 😸

😺 2
pablore 2024-12-30T14:03:41.067419Z

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!

dpsutton 2024-12-30T14:09:20.644959Z

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.edn

dpsutton 2024-12-30T14:09:31.508709Z

what if you do clj -M:dev:cider/nrepl?

dpsutton 2024-12-30T14:09:54.564559Z

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 - 

pablore 2024-12-30T14:17:52.992519Z

What does emacs say when you cider-connect to it?

oyakushev 2024-12-30T14:18:08.620419Z

Make sure you also include an explicit nrepl/nrepl {:mvn/version "1.3.0"} dependency too. The wrong version is currently pulled transitively.

❗ 1
dpsutton 2024-12-30T14:18:28.426209Z

ha. i was wondering about that and figured cider/nrepl would depend on one that worked for it

dpsutton 2024-12-30T14:19:02.786209Z

honestly surprised cider.nrepl doesn’t have a convenient entrypoint that always includes it’s middleware configured for you

oyakushev 2024-12-30T14:19:17.295889Z

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.

pablore 2024-12-30T14:19:45.477059Z

I'm still getting the warning even with both suggestions 😞

dpsutton 2024-12-30T14:20:15.003649Z

i’m a bit confused. When you used separate -M:dev -M:cider/nrepl did it not error? That’s strange to me.

oyakushev 2024-12-30T14:20:26.118039Z

Do (run! println (.split (System/getProperty "java.class.path") ":")) at the REPL.

pablore 2024-12-30T14:21:37.285159Z

@alexyakushev sending you the output in private

oyakushev 2024-12-30T14:22:22.011379Z

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.

oyakushev 2024-12-30T14:23:10.220329Z

OK, I can see they are on the classpath. So, the aliases work as intended.

oyakushev 2024-12-30T14:23:55.965859Z

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..

pablore 2024-12-30T14:24:14.873779Z

let me restart emacs

oyakushev 2024-12-30T14:24:46.894069Z

Close all Java/Clojure processes too

dpsutton 2024-12-30T14:24:57.899729Z

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

oyakushev 2024-12-30T14:25:52.075439Z

tbh, I'm not sure if -M flags are additive and not just overwrite one another

dpsutton 2024-12-30T14:26:08.926679Z

the latter is treated as std input to the process i believe

oyakushev 2024-12-30T14:26:32.278519Z

The joy of Unix shell 🥴

dpsutton 2024-12-30T14:26:33.333709Z

`: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]}],
  :trace

oyakushev 2024-12-30T14:27:38.050659Z

Explicit parentheses would save it oparen oparen oparen cparen cparen cparen

pablore 2024-12-30T14:27:46.143339Z

I changed the cmd to clj -M:dev:cider/nrepl

pablore 2024-12-30T14:28:50.237699Z

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

oyakushev 2024-12-30T14:31:52.839749Z

Yeah, good point, --middleware is likely next on the list to blame.

oyakushev 2024-12-30T14:32:15.249629Z

Are you sure your clj is an original Clojure CLI script and not some shell alias with extras?

dpsutton 2024-12-30T14:32:34.728439Z

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 same

oyakushev 2024-12-30T14:32:39.536939Z

which clj

oyakushev 2024-12-30T14:33:27.932699Z

> i think that’s on purpose? I meant it looks correct but middleware not applying is most likely the issue now.

👍 1
dpsutton 2024-12-30T14:35:25.833489Z

to answer your question, i am able to cider-connect to the instance with no warnings printed for me

dpsutton 2024-12-30T14:35:30.297759Z

dpsutton 2024-12-30T14:35:35.533469Z

pablore 2024-12-30T14:36:00.264219Z

❯ which clj
/opt/homebrew/bin/clj

oyakushev 2024-12-30T14:36:20.053789Z

Please try clojure instead of clj

dpsutton 2024-12-30T14:36:37.956399Z

@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?

pablore 2024-12-30T14:38:15.622629Z

The original cmd was a typo in slack, @dpsutton. Sorry for the confusion, I had always been using -M:dev:cider/nrepl

👍 1
pablore 2024-12-30T14:39:09.521389Z

@alexyakushev same

oyakushev 2024-12-30T14:39:23.390199Z

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?

👍 1
pablore 2024-12-30T14:40:28.147539Z

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.

pablore 2024-12-30T14:41:01.276779Z

does cider-connect inject more dependencies that I don't know about? I thought only cider-jack-in did that

oyakushev 2024-12-30T14:41:12.935749Z

Nah, it doesn't.

dpsutton 2024-12-30T14:41:27.000119Z

cider connect cannot inject dependencies. it is just connecting to a running instance that has already started up

oyakushev 2024-12-30T14:41:41.173119Z

Let's step back for a second – can you cider-jack-in into the same project and not receive the warnings?

pablore 2024-12-30T14:45:47.068699Z

Ah! cider-jack-in throws the same warning! Now I'm thinking this could be a emacs configuration problem

oyakushev 2024-12-30T14:46:48.471469Z

Yeah. I would suggest updating CIDER to the latest version, and then comment out the customizations until you get it working.

dpsutton 2024-12-30T14:47:36.752329Z

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?

oyakushev 2024-12-30T14:48:22.362799Z

Or just , classpath at the REPL should tell you that the middleware is alive.

pablore 2024-12-30T14:52:14.925729Z

both cider-apropos and , classpath work fine!

pablore 2024-12-30T14:52:25.159579Z

so perhaps this was nothing?

oyakushev 2024-12-30T14:53:27.612259Z

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.