Fork me on GitHub
#cider
<
2023-03-20
>
Richie14:03:12

How do I get cider-jack-in-clj to use a new port if the one is already in use? Usually I look for java under emacs in windows task manager and kill it but today I'm not seeing it.

[nREPL] Starting server via c\:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -encodedCommand YwBsAG8AagB1AHIAZQAgAC0AUwBkAGUAcABzACAAJwB7ADoAZABlAHAAcwAgAHsAbgByAGUAcABsAC8AbgByAGUAcABsACAAewA6AG0AdgBuAC8AdgBlAHIAcwBpAG8AbgAgACIAIgAxAC4AMAAuADAAIgAiAH0AIABjAGkAZABlAHIALwBjAGkAZABlAHIALQBuAHIAZQBwAGwAIAB7ADoAbQB2AG4ALwB2AGUAcgBzAGkAbwBuACAAIgAiADAALgAzADAALgAwACIAIgB9ACAAYwBvAG0ALgBjAGUAbQBlAHIAaQBjAGsALwBwAG8AbQBlAGcAcgBhAG4AYQB0AGUAIAB7ADoAbQB2AG4ALwB2AGUAcgBzAGkAbwBuACAAIgAiADEALgAxAC4AMAAiACIAfQAgAHIAZQBmAGEAYwB0AG8AcgAtAG4AcgBlAHAAbAAvAHIAZQBmAGEAYwB0AG8AcgAtAG4AcgBlAHAAbAAgAHsAOgBtAHYAbgAvAHYAZQByAHMAaQBvAG4AIAAiACIAMwAuADYALgAwACIAIgB9AH0AIAA6AGEAbABpAGEAcwBlAHMAIAB7ADoAYwBpAGQAZQByAC8AbgByAGUAcABsACAAewA6AG0AYQBpAG4ALQBvAHAAdABzACAAWwAiACIALQBtACIAIgAgACIAIgBuAHIAZQBwAGwALgBjAG0AZABsAGkAbgBlACIAIgAgACIAIgAtAC0AbQBpAGQAZABsAGUAdwBhAHIAZQAiACIAIAAiACIAWwByAGUAZgBhAGMAdABvAHIALQBuAHIAZQBwAGwALgBtAGkAZABkAGwAZQB3AGEAcgBlAC8AdwByAGEAcAAtAHIAZQBmAGEAYwB0AG8AcgAsAGMAaQBkAGUAcgAuAG4AcgBlAHAAbAAvAGMAaQBkAGUAcgAtAG0AaQBkAGQAbABlAHcAYQByAGUAXQAiACIAXQB9AH0AfQAnACAALQBNADoAYwBpAGQAZQByAC8AbgByAGUAcABsAA==
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: #< CLIXML

ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized 
where the encoded command is
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version ""1.0.0""} cider/cider-nrepl {:mvn/version ""0.30.0""} com.cemerick/pomegranate {:mvn/version ""1.1.0""} refactor-nrepl/refactor-nrepl {:mvn/version ""3.6.0""}} :aliases {:cider/nrepl {:main-opts [""-m"" ""nrepl.cmdline"" ""--middleware"" ""[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]""]}}}' -M:cider/nrepl

Richie14:03:10

doom emacs

dpsutton14:03:20

i think by default it uses a random open port. Have you configured it to use a definite port somehow?

Richie14:03:48

I deleted the .nrepl-port file just in case.

dpsutton14:03:02

that doesn’t affect anything. That file is created when the port is chosen. It doesn’t direct which port to choose

dpsutton14:03:33

the standard workflow is “grab an empty port and start the nrepl server there. Then write that port to .nrepl-port so tooling knows which to use”

dpsutton14:03:56

if you are getting an error that the port is already taken, I think it means somewhere you are specifying which port to use.

Richie14:03:59

I just made a new folder where deps.edn says {:paths ["src"] :deps {}} and src/core.clj says (ns core) (defn hello [] (println "hello world")) and I get:

[nREPL] Starting server via c\:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -encodedCommand YwBsAG8AagB1AHIAZQAgAC0AUwBkAGUAcABzACAAJwB7ADoAZABlAHAAcwAgAHsAbgByAGUAcABsAC8AbgByAGUAcABsACAAewA6AG0AdgBuAC8AdgBlAHIAcwBpAG8AbgAgACIAIgAxAC4AMAAuADAAIgAiAH0AIABjAGkAZABlAHIALwBjAGkAZABlAHIALQBuAHIAZQBwAGwAIAB7ADoAbQB2AG4ALwB2AGUAcgBzAGkAbwBuACAAIgAiADAALgAzADAALgAwACIAIgB9ACAAYwBvAG0ALgBjAGUAbQBlAHIAaQBjAGsALwBwAG8AbQBlAGcAcgBhAG4AYQB0AGUAIAB7ADoAbQB2AG4ALwB2AGUAcgBzAGkAbwBuACAAIgAiADEALgAxAC4AMAAiACIAfQAgAHIAZQBmAGEAYwB0AG8AcgAtAG4AcgBlAHAAbAAvAHIAZQBmAGEAYwB0AG8AcgAtAG4AcgBlAHAAbAAgAHsAOgBtAHYAbgAvAHYAZQByAHMAaQBvAG4AIAAiACIAMwAuADYALgAwACIAIgB9AH0AIAA6AGEAbABpAGEAcwBlAHMAIAB7ADoAYwBpAGQAZQByAC8AbgByAGUAcABsACAAewA6AG0AYQBpAG4ALQBvAHAAdABzACAAWwAiACIALQBtACIAIgAgACIAIgBuAHIAZQBwAGwALgBjAG0AZABsAGkAbgBlACIAIgAgACIAIgAtAC0AbQBpAGQAZABsAGUAdwBhAHIAZQAiACIAIAAiACIAWwByAGUAZgBhAGMAdABvAHIALQBuAHIAZQBwAGwALgBtAGkAZABkAGwAZQB3AGEAcgBlAC8AdwByAGEAcAAtAHIAZQBmAGEAYwB0AG8AcgAsAGMAaQBkAGUAcgAuAG4AcgBlAHAAbAAvAGMAaQBkAGUAcgAtAG0AaQBkAGQAbABlAHcAYQByAGUAXQAiACIAXQB9AH0AfQAnACAALQBNADoAYwBpAGQAZQByAC8AbgByAGUAcABsAA==
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: #< CLIXML

ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [s\src\jdk.jdwp.agent\share\native\libjdwp\debugInit.c:734]
<Objs Version="1.1.0.1" xmlns=""><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="2"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="3"><TNRef RefId="0" /><MS><I64 N="SourceId">3</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs> ("finished")
error in process sentinel: Could not start nREPL server: #< CLIXML

ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [s\src\jdk.jdwp.agent\share\native\libjdwp\debugInit.c:734]
<Objs Version="1.1.0.1" xmlns=""><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="2"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="3"><TNRef RefId="0" /><MS><I64 N="SourceId">3</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs> ("finished")

Richie14:03:41

I’m going to just reboot to make the error go away. It does happen somewhat regularly though so I'm interested in next steps for debugging it. I guess I can try debugging cider's elisp...

dpsutton14:03:42

Have you setup the configuration files by any chance?

dpsutton14:03:27

there are two files: • in your local directory .nrepl.edn` • and globally at .nrepl/nrepl.edn``

Richie14:03:40

I don't have .nrepl.edn in my project dir nor .nrepl/ in my home dir.

dpsutton14:03:06

then i do not understand why it cannot find a port. sorry

Richie14:03:26

Ok, thanks.

Richie14:03:05

It's good to know that I haven't messed up the configuration.

Richie14:03:04

When cider tries to find an open port, how does that work? It's like a try/catch?

dpsutton14:03:13

cider does not

Richie14:03:23

Oh, clojure?

dpsutton14:03:38

nrepl itself tries. If you pass port 0 it will use a random port and tell you which

dpsutton14:03:03

i doubt it is a try catch. But not sure what parts are provided by OS and which in the application

Richie14:03:11

What's the difference between passing in 0 and not configuring it?

dpsutton14:03:33

i don’t believe there is a difference. By not configuring it you get the default which will pass a 0

Richie14:03:38

Ok, thanks.

Richie14:03:26

Oh, so, as a debugging step, I should try configuring a port to see if it will work?

dpsutton14:03:48

It’s a little difficult because you are on powershell and things have to be base64 encoded. But I would try to get everything running without CIDER and then add it in when you know everything works

Patrick Brown16:03:30

Is there a way to just run cider-connect twice and connect to an already running clojure-cli and an already running shadow-cljs server. And then be able to have a workflow where I tell cider which repl I am trying to evaluate in buffer code to? I hope this question isn't missing the plot, it's just, I'm struggling to the point of all out confusion. I'd like to be able to work primarily on clj/cljc code, but at moments add a little cljs code and be able to troubleshoot why it's broken in a repl instead of reading errors in the browser. Every attempt to try this whole sibling thing only enhances my confusion as to what I'm trying to accomplish and what my emacs is doing.

hifumi12318:03:20

IIRC when I run shadow-cljs embedded in lein there is an nrepl middleware one has to add so CIDER can connect to the shadow-cljs REPL. But otherwise it should be as simple as something like M-x cider-connect-clj&cljs, if I remember the command correctly

hifumi12318:03:11

Worst case scenario you can use dir-locals to set up a custom cljs REPL command that properly sets up shadow-cljs when you jack in