Fork me on GitHub
#calva
<
2024-05-01
>
fadrian16:05:14

This morning when I tried to jack in to a new REPL in a project using deps.edn, I saw these messages in the terminal: ️ Starting the REPL ️ using the below command line: pushd c:\Users\fadrian\Projects\mocktserv & java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""1.1.1""},cider/cider-nrepl {:mvn/version,""0.47.1""}}}" -M:dev -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" & popd Error while parsing option "--config-data {:deps {nrepl/nrepl {:mvn/version,\"1.1.1},cider/cider-nrepl": java.lang.RuntimeException: EOF while reading string Jack-in process exited. Status: 1 Needless to say, the fresh REPL was not started. I don't see anything wrong with the -Sdeps parameter (from which the --config-data parameter seems to be derived) so I am at a loss as to what is causing this error. I am using the latest release of the Calva extension - 2.0.451. I tried installing an earlier version (2.0.448) but it didn't change anything so I suspect the problem is environmental and has nothing to do with the extension. Any ideas?

vemv16:05:46

The pl/nrepl {:mvn/version,\"1.1.1}, part looks broken (unmatched \")

fadrian16:05:16

I did notice that, so the error made sense to me, but I don't know the process for starting the REPL, so I'm not sure how to work around this.

seancorfield16:05:02

Looks like a quoting incompatibility with whatever shell is trying to run the jack-in command. I see a Windows file path there. See https://clojure.org/reference/clojure_cli#quoting for the additional complexity that cmd and PS cause. @U0ETXRFEW How does Calva determine the platform in order to provide the correct quotes here?

Alex Miller (Clojure team)17:05:32

^^ pwsh 7.3 changes not yet accounted for in the docs

pez18:05:44

Iirc Calva quotes for cmd.exe and Jack-in should be using cmd.exe. But I could have that wrong. @U0DTU8J83, what you can try is to use the command Calva: Copy Jack-In Command Line to Clipboard and then use that command line in a cmd.exe shell. If that works, then maybe what happens is that Powershell somehow gets to handle the command line. I usually have a Windows machine I can spawn in the cloud to test on, but I don’t at the moment.

fadrian20:05:32

I did what you suggested. I got back the same command line as the message said: pushd c:\Users\fadrian\Projects\mocktserv & java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""1.1.1""},cider/cider-nrepl {:mvn/version,""0.47.1""}}}" -M:dev -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" & popd When I ran this command line manually, rather than erroring out, it started two tasks and seemed to terminate without an error. I have no issue with doing this each time I restart the REPL, if it gets me going again. Is there any way to connect to one of these tasks to provide REPL functionality?

pez06:05:18

Is taks the same as processes/programs? The clojure process shouldn’t terminate. If one of those tasks is still running and is indeed the clojure process, you should be able to connect Calva to it with the command Calva: Connect to a Running REPL Server in the Project.

fadrian19:05:41

Starting the server manually and then connecting to a running REPL works.

pez19:05:35

Then maybe Calva doesn’t make sure that jack-in runs in cmd.exe. I’ve tried to convince it to do this in this build of Calva: • https://output.circle-artifacts.com/output/job/1c124d51-c394-441b-b118-879fe53a81ed/artifacts/0/tmp/artifacts/calva-2.0.452-jack-in-win-cmd-exe-34bb11a4.vsix Can you install and see if jack-in starts to work for you, @U0DTU8J83? You find the option to install from VSIX in the topmost meatballs menu of the Extensions pane. When downloading the package it sometimes changes extension to .zip, and then you need to change it back to vsix for VS Code to allow you to install it.

pez15:05:05

I got my hands on a Windows machine today and could reproduce the problem two times. Then it started to work consistently, unfortunately, so I didn’t really have a chance to fix it.

Alexander Kouznetsov22:05:56

What might be triggering these stacktraces? I have a bunch of them and my java CPU usage reaches 1000%.

dpsutton22:05:21

that looks like a manually initiated stack dump?

dpsutton22:05:06

but it’s orchard.java.parser > “Source and docstring info for Java classes and members. > Parses :docs using Markdown. > This ns is automatically discarded if orchard.java.parser-next can be loaded.”

Alexander Kouznetsov23:05:46

Yes, I was exploring this using jps. It makes my CPU very busy and I’m trying to figure out how to suppress it if possible.

Alexander Kouznetsov17:05:47

I have 29 send-off threads total in my thread dump. 17 of them are busy with something like above.

Alexander Kouznetsov17:05:12

It became unusable to connect to REPL from vscode. When I ran it standalone (from command line) this doesn’t happen.

dpsutton18:05:39

yeah. you’ll need help from #C0617A8PQ or #CBE668G4R. Seems like lots of background processing. Not sure how to inhibit that

🙌 1
vemv18:05:05

It's started over here https://github.com/clojure-emacs/cider-nrepl/blob/79611e47615bc00ea00fe9c265da896976324ae0/src/cider/nrepl.clj#L75-L77 While it has its uses in CIDER, most likely it doesn't have much/any in Calva.

🙌 1
vemv18:05:31

In my computer (8-core intel MBP), while there' s an initial spike, that's it basically. Anyway, I don't think we parallelize this - fairly certain of that since the underlying Java code is thread-unsafe. In order to proceed please: • create an issue in Calva • cc/ me • Attach gists with all thread dumps from all relevant threads. ◦ Highly valuable since I never heard of this workload being parallelized. Thanks!

🙌 1
Alexander Kouznetsov18:05:33

From -Stree it looks like we must be using a much older version of this code: cider/cider-nrepl {:mvn/version "0.28.5"}.

vemv18:05:47

That's right, Orchard (as seen in the stacktrace) is also at a very old version Then scratch what I said

🙌 1
vemv18:05:50

Do you have the JDK sources in your project? Probably older Orchard and cider-nrepl combinations are bad at handling those

Alexander Kouznetsov18:05:18

You mean Java source files? Yes we do.

Alexander Kouznetsov18:05:43

I guess it is a good reason to bump the versions.

vemv18:05:12

> You mean Java source files? Yes we do. From the JDK itself, yes

Alexander Kouznetsov18:05:13

Hmm, not sure what that is. We do have a bunch of java files, but that what we generate. Not JDK ones.

Alexander Kouznetsov18:05:26

I guess vscode allows to jump into JDK sources, maybe that could trigger something like that?

vemv18:05:27

Maybe. Anyway I can only respond for (latest-version) cider and orchard and don't know much about Calva stuff 😬

pez18:05:38

That shouldn’t trigger any stacktraces in the app. At least I can’t see how that happens.

pez19:05:35

Try run it with the nrepl log active and see if you can spot which op is triggering the behaviour.

vemv19:05:35

Very likely it's "info" since the stacktrace hits $info_reply

Alexander Kouznetsov19:05:19

Interesting, I have 40 error responses to a single calva nrepl request ‘14’ which looks like related to this, but I didn’t capture the request itself. I’ll try again.