@mauricio.szabo I just upgraded to the latest Clover and hoped to try out the socket file detection and got this:
dev=> (slurp ".socket-repl-port")
"5000"
So the file is in the root of where the REPL was started although I don’t know how Clover searches for the file? It’s not in the overall project root — Would it search up the tree from the file that is open when I try to connect to a REPL?Clover searches for all project directories for this file. It's strange that this <
is happening tho...
What do you mean by “all project directories”?
My project is setup like this:
repo/
clojure/
.socket-repl-port
subproject-a/
subproject-b/
Source files are under subprojects. VS Code is opened at repo/
. Would Clover find that file?
In this case, theres' a single project directory: repo
.
You can add multiple directories to the workspace, and Clover will try to search all of then
So Clover won’t find the file because it’s not in the (root) of the project directory?
I’ll test it some more later, but I’m also getting “Port must be a number” sometimes…
Great! The are some tricks to not stop auto-detection if you don't change the port from the connection popup, so if you find that Clover keeps the old port instead of detecting a new one when you restart the REPL, please let me know 🙂
(I also know that you keep REPLs open for weeks, so maybe this can be a non-issue for you 😄)
Yeah, I just saw that issue: I started a REPL, connected from Clover and it prompted with the correct port. I quit and restarted the REPL (which got a different port) and when I went to connect, Clover prompted with the old port instead of re-reading the file. I did “Reload Window” and it picked up the new port.
I’m not likely to follow that workflow: I’m much more likely to quit and restart VS Code between sessions (of work) and keep the REPL running all the time. But it may be weird/confusing for other people.
On my tests, sometimes it kept the old port, sometimes it didn't. I'll revisit this code....
I'll check these "Port must be a number" also. See what's wrong
Also, yes, Clover won't find the file. It's the same problem with an issue that exist for some time (https://github.com/mauricioszabo/atom-chlorine/issues/205), because it's hard to know where to look and how deep to go to check for the port files
Perhaps check up the tree from where the currently open file is up to the project root folder?
That seems to be what a lot of tools do. Like .gitignore
and several other dot files.
This can work. I'll look at this issue 🙂
Thanks @mauricio.szabo! I really like that it is defaulting to the socket I used in most of my projects now. Only my work project has .socket-repl-port
at the “wrong” level and that’s because our repo has a clojure
tree and a build
tree…
(for now I put a symlink from <repo>/clojure/.socket-repl-port
to <repo>/.socket-repl-port
so it “works”)
I’ve recently changed my dev setup so I use port zero which opens a socket REPL on a random available port, and now Clover reads the file, so I don’t have to remember which port it chose! 🙂
BTW, what's not to love about vscode right? Version 1.51.1-1605051630
Version 1.55.0-1617120720
Well, reported the bug 😄 https://github.com/microsoft/vscode/issues/120593
Wow, thank you so much. I was wondering how to open multiple connections without having to keep track of the open ports. Didn’t know about the 0 trick.
https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L123-L126 or https://github.com/seancorfield/dot-clojure/blob/develop/dev.clj#L196-L215 from my dev setup.
I have SOCKET_REPL_PORT=0
in my .profile
🙂
I start a REPL like this:
(! 1004)-> clojure -M:rebel:reveal:test:dev:dev/repl
Downloading: vlaaad/reveal/maven-metadata.xml from clojars
Downloading: com/bhauman/rebel-readline/maven-metadata.xml from clojars
Downloading: vlaaad/reveal/1.3.199/reveal-1.3.199.pom from clojars
Downloading: vlaaad/reveal/1.3.199/reveal-1.3.199.jar from clojars
Selected port 55961 for the Socket REPL...
Starting Reveal+Rebel Readline as the REPL...
Clojure 1.10.3
dev=>
The thing is that I mostly deal with lein
projects - but yeah, I’m doing something kinda equivalent, just adding this JVM option to my lein
profile. But good to know.
Ah, we haven’t used lein
at work for years…