Fork me on GitHub
#cursive
<
2022-09-08
>
Vincent Cantin08:09:03

Hi, I updated Cursive to the latest version today and I get an error when trying to open a remote nREPL to a local Shadow-CLJS runtime: Exception starting REPL: java.lang.IllegalStateException: Could not open new session; :clone response: Disconnected from remote server. Do you have an idea where the problem comes from and how to work around it?

👀 1
cfleming09:09:48

I don’t, sorry. Perhaps try asking in #shadow-cljs, and if you don’t get anywhere there I’ll look at it tomorrow morning.

Vincent Cantin09:09:46

It was working before I update intellij and cursive.

cfleming09:09:08

Do you know which version you were on before?

cfleming09:09:38

This is connecting to the Shadow Clojure REPL, right? Not the CLJS one?

Vincent Cantin09:09:56

Yes, the Clojure one

cfleming09:09:53

Ok, I’ll try this with a Shadow project tomorrow. Is your project public?

Vincent Cantin09:09:27

I don't know which version exactly, but I know that it was the latest intellij and cursive version I was able to use with my license expired on March 23th. I renewed the license this morning.

Vincent Cantin09:09:46

The project is not public.

cfleming09:09:15

Ok, I’ll try with some shadow projects I have lying around.

Vincent Cantin09:09:47

I just found that it works if I connect by setting the host + port

1
Vincent Cantin09:09:34

It also works when I set the port file to .shadow-cljs/nrepl.port manually

1
Vincent Cantin09:09:00

It doesn't work when I choose the "Use standard port file"

1
thheller17:09:59

you probably have another port file lingering around with a dead port?

Vincent Cantin03:09:41

I didn't find such file. When shadow-cljs (2.19.5) is not running and I try to connect a repl from the IDE using "Use standard port file", I get a different error from the IDE in a notification bubble saying "Cannot find port from port file". So I guess it is not a problem with a lingering port file. for info, when shadow-cljs is running:

$ ls .shadow-cljs
babel-worker     cli-repl.port    jar-manifest     server.pid       socket-repl.port
builds           http.port        nrepl.port       server.token

Dustin Getz20:09:44

I also have this – i updated Cursive first, and then a couple days later upgraded CLJS and Shadow to

org.clojure/clojurescript {:mvn/version "1.11.60"}
thheller/shadow-cljs {:mvn/version "2.20.1"}
at which point i believe i got the error. Found this thread by global search, I did not suspect Cursive. Sitting down now to try to triangulate

Dustin Getz20:09:57

Ok, on Cursive 1.12.5-eap1-2022.1, Cursive Clojure Local REPL, nREPL, Run With Deps, on startp a .nrepl-port is produced in project root.

Starting nREPL server...
WARNING: compile already refers to: #'clojure.core/compile in namespace: user, being replaced by: #'user/compile
Connecting to local nREPL server...
Clojure 1.11.1
nREPL server started on port 56232 on host localhost - 
Immediately - now Cursive Remote REPL, nrepl, use port from REPL file in project ..., use standard port file:
Connecting to remote nREPL server...
Clojure 1.11.1
Close remote REPL Now when I run
(def shadow-start! (delay @(requiring-resolve 'shadow.cljs.devtools.server/start!)))
(@shadow-start!)
output is now:
Starting nREPL server...
WARNING: compile already refers to: #'clojure.core/compile in namespace: user, being replaced by: #'user/compile
Connecting to local nREPL server...
Clojure 1.11.1
nREPL server started on port 56232 on host localhost - 
(@shadow-start!)
shadow-cljs - server version: 2.20.1 running at 
shadow-cljs - nREPL server started on port 9001
=> :shadow.cljs.devtools.server/started
additionally, a second .nrepl-port file is produced shadow-cljs/.nrepl-port Cursive Remote REPL, autodetect port:
Connecting to remote nREPL server...
Exception starting REPL: java.lang.IllegalStateException: Could not open new session; :clone response: Disconnected from remote server.

Dustin Getz20:09:42

Clojure and Shadow version doesn't impact this, I can repro these steps with the following two configurations:

org.clojure/clojurescript {:mvn/version "1.11.60" #_"1.11.4"}
thheller/shadow-cljs {:mvn/version "2.20.1" #_"2.18.0"}

Dustin Getz20:09:11

Explicitly setting the CLJS nrepl port to shadow-cljs/.nrepl-port obviously fixes the error

Dustin Getz20:09:48

Did the autodetect rules change or did the generation of the file change in either Cursive or Shadow recently? Not sure why this is suddenly happening or where the bug is or if there even is a bug

cfleming21:09:14

Thanks for the repro information, I’ll try to repro that today. I don’t think the autodetect rules have changed recently. Thomas might know if shadow’s generation of port files has changed, although it seems like maybe a change to nREPL is generating the .nrepl-port rather than Shadow doing it.

👀 1
thheller21:09:11

yeah, shadow-cljs parts haven't changed in forever

thheller21:09:26

however I upgraded to nrepl 1.0 and didn't check what it is doing in those regards

👀 1
thheller21:09:34

maybe it just always creates this file?

cfleming21:09:38

Ok, I’ll try to repro that and see if I can figure out what’s going on.

thheller21:09:16

2.20.0 was the upgrade to nrepl 1.0

Dustin Getz21:09:53

Ok I will check again now, maybe I didn't cleanly test when i reverted back to 2.18.0

cfleming21:09:16

Just to be clear, it looks like you’re starting the Shadow REPL using a Cursive nREPL config rather than on the command line, correct?

Dustin Getz21:09:12

Um i am calling shadow.cljs.devtools.server/start! from cursive Local repl to start shadow's nrepl

Dustin Getz21:09:43

this results in two running nrepl services, one from the Cursive local repl and one from Shadow – which I did not realize I was doing until today

cfleming21:09:14

So in that case, I’d expect to see what you’re seeing in terms of port files. Starting the nREPL server via the Cursive nREPL config will create .nrepl-port, and Shadow’s nREPL will create .shadow-cljs/.nrepl-port. However I don’t think any of that has changed in a long time, and it shouldn’t cause an error obviously.

cfleming21:09:08

However my impression is that Vincent wasn’t doing that, since he said he didn’t find an .nrepl-port file.

Dustin Getz21:09:23

Carefully testing with shadow-cljs "2.18.0" (rm -rf .shadow-cljs && rm .nrepl-port) and I still repro - i can see the Cursive Local REPL create .nrepl-port within a few seconds of startup

Dustin Getz21:09:52

i dont think a shadow 2.20 change is in play

cfleming21:09:18

Ok, thanks.

Aron06:09:37

I have this error too, but in my case neither of the options result in a running repl I suspect it's because I want to connect to a shadow repl inside wsl2 from windows

Aron14:09:38

moved from wsl2 to just using git bash and I am here https://gist.github.com/ashnur/9264574919de333e463e591a9fcba008 Not even sure where to look after this. Will have to try with a different editor.

Dustin Getz14:09:10

Cursive 1.12.5-eap1 - 2022-08-03 Add ability for socket REPL to pick up the port from a file #2695

Andrea16:01:46

Hello cursivians 👋 ! I actually do have the same issue after upgrading to Cursive 1.12.7-2022.3 with IntelliJ IDEA 2022.3.2 (CE). My nREPL is started by an external process and puts a file .nrepl-port at project source root. My setting Edit Configurations > Remote REPL > Use port from REPL file &gt; Us_e standard port file_ no longer works and produces:

2023-01-31 17:35:50,752 [  93130] SEVERE - #cursive.repl.nrepl - Error reading from nREPL client
java.lang.ArithmeticException: long overflow
 at java.lang.Math.multiplyExact (Math.java:1004)
    clojure.lang.Numbers.multiply (Numbers.java:1971)
    nrepl.bencode$read_long.invokeStatic (bencode.clj:129)
    nrepl.bencode$read_long.invokePrim (bencode.clj:-1)
    nrepl.bencode$read_long.invokeStatic (bencode.clj:127)
    nrepl.bencode$read_long.invokePrim (bencode.clj:-1)
    nrepl.bencode$read_long.invokeStatic (bencode.clj:127)
    nrepl.bencode$read_long.invokePrim (bencode.clj:-1)
    nrepl.bencode$read_long.invokeStatic (bencode.clj:127)
    nrepl.bencode$read_long.invokePrim (bencode.clj:-1)
    nrepl.bencode$read_netstring_STAR_.invokeStatic (bencode.clj:156)
    nrepl.bencode$read_netstring_STAR_.invoke (bencode.clj:154)
    nrepl.bencode$read_token.invokeStatic (bencode.clj:247)
    nrepl.bencode$read_token.invoke (bencode.clj:237)
    nrepl.bencode$read_bencode.invokeStatic (bencode.clj:257)
    nrepl.bencode$read_bencode.invoke (bencode.clj:254)
    nrepl.transport$bencode$fn__4147$fn__4148.invoke (transport.clj:113)
  
when I try to run the REPL from Cursive.

Andrea16:01:49

By setting the option Specify custom port file to .nrepl-port it does connect fine.

Andrea16:01:48

We don’t start our nREPL via shadow

salam19:03:27

@U0567Q30W I haven’t been able to start a Cursive nREPL client due to this issue for a while. I thought it was an issue with our configuration until I saw this thread. Steps to reproduce: 1) start a ShadowCLJS app in the terminal, which also automatically starts an nREPL server and creates an nrepl.port file (among others) under .shadow-cljs directory (which is .gitignored and Excluded, if that helps) 2) start a Cursive remote nREPL client and select "Use standard port file" under “Use port from REPL file” Switching to “Specify custom port file” and providing .shadow-cljs/.nrepl-port fix the problem.

thheller20:03:17

I saw that Crusive now lists .shadow-cljs/nrepl|socket-repl.port in the repl remote dialog? could be that it tries the socket-repl.port even though nrepl is selected?

☝️ 2
thheller20:03:28

or do you maybe have socket REPL selected, and it is trying the nrepl?

salam20:03:10

as I mentioned above, switching to manually specifying the port file fixes the problem within same nREPL Run Configuration.

salam20:03:07

Switching to Socket REPL starts a REPL just fine as ShadowCLJS starts a socket REPL server and creates the port file for it as well.

salam20:03:28

Something seems off with the combination of nREPL, ShadowCLJS, and the automatic port file detection.

cfleming20:03:59

Thanks for the repro steps, I’ll look at this today.

👍 2
❤️ 2
cfleming01:03:53

This was reported as https://github.com/cursive-ide/cursive/issues/2759, and is fixed for the next build. I’ll try to get this out today. My apologies for this taking so long.

🎉 4
gratitude-thank-you 6
🙏 2
octahedrion14:09:35

I don't know if this is Cursive thing or an IntelliJ thing but is there a way to make project structure > modules default to excluded for all subfolders ? I'm pretty sure IntelliJ eagerly indexes everything not exluded in there, including folders like .cpcache, .git, .circleci etc

Jordan Robinson15:09:35

this may or may not help, but I've found if you open the .gitignore in intellij in recent versions it will ask you if you want to add everything there into excluded folders

Jordan Robinson15:09:14

though I can't say I've seen intellij indexing the .git folder myself

octahedrion08:09:44

thanks but that tells IntelliJ to totally ignore those files/folders, i.e. they won't even appear in the project view, whereas I still want to see some such folders in the project view, but I want them excluded from indexing