Closed BorisVSchmid closed 1 year ago
Seems like -r
prevents socket server from starting. Maybe ask clojure cli folks if that’s intended? @puredanger?
-r is a clojure.main flag that you can use with -M. -M and -X are different modes of the CLI, so as is, this does not make sense and you should not expect it to work.
An alternate way to do this would be to use -M with -r and launch the socket server via system properties rather than via -X. This would be something like:
clj "-J-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl :server-daemon false}" -M -r
Since -r is the default mode with -M, you can then simplify it to:
clj "-J-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl :server-daemon false}"
Sorry to revisit, but somewhere it doesnt work for me.
From a powershell, I can do
PS C:\Users\boris> clj "-J-Dclojure.server.repl={:port 1515 :accept clojure.core.server/repl :server-daemon false}"
Clojure 1.11.1
user=>
And that works fine.
I can check a socket is open
(import '(java.net Socket SocketTimeoutException))
(defn check-repl-running-with-timeout [host port timeout-ms]
(try
(let [socket (Socket.)]
(.connect socket (java.net.InetSocketAddress. host port) timeout-ms)
(.close socket)
true)
(catch SocketTimeoutException _ false)
(catch Exception _ false)))
user=> user=> #'user/check-repl-running-with-timeout
user=> user=> user=> (check-repl-running-with-timeout "localhost" 1515 2000)
true
And that works fine.
I can create a minimal clojure project (deps.edn in the main directory and a core.clj within a src/minimal/ directory), and I can connect to the socket repl with "Clojure sublimed: Connect to Socket REPL".
deps.edn:
{:description "Sockety"
:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}}}
core.clj:
(ns minimal.core)
(+ 3 1)
and Sublime indicates I am connected to localhost:1515.
But when I try to evaluate core.clj, I get the two spinning \ and nothing happens.
I am on windows 11 pro
PS C:\Users\boris> clj --version
Clojure CLI version 1.11.1.1165
PS C:\Users\boris> java --version
java 21.0.2 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)
Sublime Text 4169
Clojure Sublimed 3.7.2
Other packages within sublime are Terminus, SublimeLinter, Package Control, SublimeLinter-contrib-clj-kondo.
Anything I am missing that is making socket repl not work? Thanks in advance.
Should be fixed in 3.7.3
Just tried to switch from nrepl (all works fine for me) to socket repl. Clojure-Sublimed can connect to a socket repl started with Terminus when I start the socket repl as follows:
clj -X clojure.core.server/start-server :name repl :port 5555 :accept clojure.core.server/repl :server-daemon false
but not when I start with the -r flag, to also have access to the repl (and some place to see printed output happen).
clj -r -X clojure.core.server/start-server :name repl :port 5555 :accept clojure.core.server/repl :server-daemon false
But there might be a more fundamental problem on windows. If I evaluate a buffer, I do get the spinning wheels per top-level function (nice!), but it never seems to finish evaluation.