Fork me on GitHub
#chlorine-clover
<
2021-04-05
>
seancorfield19:04:57

@mauricio.szabo I just upgraded to the latest Clover and hoped to try out the socket file detection and got this:

seancorfield19:04:11

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?

mauricio.szabo19:04:14

Clover searches for all project directories for this file. It's strange that this < is happening tho...

seancorfield19:04:02

What do you mean by “all project directories”?

seancorfield19:04:56

My project is setup like this:

repo/
    clojure/
      .socket-repl-port
      subproject-a/
      subproject-b/

seancorfield19:04:24

Source files are under subprojects. VS Code is opened at repo/. Would Clover find that file?

mauricio.szabo19:04:35

In this case, theres' a single project directory: repo.

mauricio.szabo19:04:26

You can add multiple directories to the workspace, and Clover will try to search all of then

seancorfield19:04:53

So Clover won’t find the file because it’s not in the (root) of the project directory?

seancorfield19:04:01

I’ll test it some more later, but I’m also getting “Port must be a number” sometimes…

seancorfield05:04:10

Overall, this is working really well... I love that I can just start a Socket REPL on "port 0" in a project with my :dev/repl alias and then connect in VS Code and it knows what port to default to. Thanks, @mauricio.szabo! This is a great time-saver!

mauricio.szabo13:04:26

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 🙂

mauricio.szabo13:04:40

(I also know that you keep REPLs open for weeks, so maybe this can be a non-issue for you 😄)

seancorfield17:04:05

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.

seancorfield17:04:00

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.

mauricio.szabo17:04:39

On my tests, sometimes it kept the old port, sometimes it didn't. I'll revisit this code....

mauricio.szabo22:04:48

I'll check these "Port must be a number" also. See what's wrong

mauricio.szabo22:04:57

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

seancorfield22:04:17

Perhaps check up the tree from where the currently open file is up to the project root folder?

seancorfield22:04:26

That seems to be what a lot of tools do. Like .gitignore and several other dot files.

mauricio.szabo22:04:07

This can work. I'll look at this issue 🙂

seancorfield22:04:42

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…

seancorfield22:04:13

(for now I put a symlink from <repo>/clojure/.socket-repl-port to <repo>/.socket-repl-port so it “works”)

seancorfield22:04:10

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! 🙂

💯 3
apt22:04:11

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.

seancorfield23:04:04

I have SOCKET_REPL_PORT=0 in my .profile 🙂

seancorfield23:04:31

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=> 

seancorfield23:04:54

Then code . and ctrl-; y and Clover prompts with localhost:55961 (in 0.2.3) because it reads the .socket-repl-port file laid down by my :dev/repl alias startup code.

apt23:04:57

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.

seancorfield23:04:07

Ah, we haven’t used lein at work for years…

👍 3
apt02:04:18

Sean, so you always start a repl from the command line and manually input the generated port number in VSCode? I’m just wondering if there’s a way to connect the editor automatically – I actually use Emacs, but I guess the problem is the same.

seancorfield02:04:35

I always start the REPL from the command-line -- because my REPLs are very long-lived.

seancorfield02:04:53

Whereas I have to restart VS Code more often 🙂

seancorfield02:04:24

The REPL I've been using to work on HoneySQL V1 has been running since January 31st!

apt02:04:08

Oh, okay. Now it makes sense that your setup is able to add libs dynamically etc (saw your talk). Yeah, for that use case I guess the pain of connecting to a repl is minimal 🙂

seancorfield02:04:41

My main work REPL has been running since March 24th (I just ssh'd into my desktop from my laptop, then used telnet to connect to the work REPL, and ran (dev/up-since) which is part of my dot-clojure setup (a function in my dev.clj file).

seancorfield02:04:26

I have four REPLs running on my desktop I think.

apt03:04:50

Got it. I deal with micro-services so I have to start multiple repls very often. I don’t want to keep the repls alive because they eat a considerable amount of memory - for example, I just started a nrepl for one micro-service and it’s taking 1,5gb of ram (while I’m doing nothing). To be honest, I’m surprised with this – never had realised that before testing this now

apt03:04:01

(oh, there’s an integration project that uses deps.edn and load multiple services libraries and knows how to wire them together so that you’re able to use the test components for integration tests that involves multiple services - that’s the project the resembles a monorepl the most, but still, it’s another beast.)

seancorfield03:04:24

That's what we do at work: a single REPL with our entire codebase accessible -- 40+ subprojects making up about 14 services.

seancorfield03:04:05

I talk a bit about our structure here https://corfield.org/blog/2021/02/23/deps-edn-monorepo/ There's also Polylith, which also works around a single dev REPL with the entire codebase available but everything organized in a modular way @U976F1AR2

apt03:04:34

nice , will have a look at it.

mauricio.szabo22:04:26

BTW, what's not to love about vscode right? Version 1.51.1-1605051630

mauricio.szabo22:04:39

Version 1.55.0-1617120720

6
seancorfield23:04:54

Then code . and ctrl-; y and Clover prompts with localhost:55961 (in 0.2.3) because it reads the .socket-repl-port file laid down by my :dev/repl alias startup code.

seancorfield05:04:10

Overall, this is working really well... I love that I can just start a Socket REPL on "port 0" in a project with my :dev/repl alias and then connect in VS Code and it knows what port to default to. Thanks, @mauricio.szabo! This is a great time-saver!