chlorine-clover

seancorfield 2021-04-05T19:19:57.040900Z

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

seancorfield 2021-04-05T19:22:11.042600Z

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.szabo 2021-04-05T19:28:14.043600Z

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

seancorfield 2021-04-05T19:31:02.043900Z

What do you mean by “all project directories”?

seancorfield 2021-04-05T19:31:56.044800Z

My project is setup like this:

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

seancorfield 2021-04-05T19:32:24.045400Z

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

mauricio.szabo 2021-04-05T19:40:35.045900Z

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

mauricio.szabo 2021-04-05T19:41:26.046400Z

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

seancorfield 2021-04-05T19:54:53.047Z

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

seancorfield 2021-04-05T19:57:01.047700Z

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

seancorfield 2021-04-06T05:03:10.060Z

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.szabo 2021-04-06T13:30:26.060300Z

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.szabo 2021-04-06T13:30:40.060500Z

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

seancorfield 2021-04-06T17:10:05.060700Z

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.

seancorfield 2021-04-06T17:11:00.060900Z

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.szabo 2021-04-06T17:12:39.061100Z

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

mauricio.szabo 2021-04-05T22:07:48.048Z

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

mauricio.szabo 2021-04-05T22:08:57.049100Z

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

seancorfield 2021-04-05T22:11:17.050200Z

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

seancorfield 2021-04-05T22:11:26.050500Z

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

mauricio.szabo 2021-04-05T22:12:07.051200Z

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

seancorfield 2021-04-05T22:14:42.052300Z

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…

seancorfield 2021-04-05T22:15:13.053Z

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

seancorfield 2021-04-05T22:16:10.053900Z

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

💯 1
apt 2021-04-05T22:55:11.055700Z

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.

seancorfield 2021-04-05T23:07:04.056300Z

I have SOCKET_REPL_PORT=0 in my .profile 🙂

seancorfield 2021-04-05T23:08:31.056500Z

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

seancorfield 2021-04-05T23:09:54.056700Z

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.

apt 2021-04-05T23:11:57.057Z

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.

seancorfield 2021-04-05T23:26:07.057200Z

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

👍 1
apt 2021-04-06T02:49:18.057500Z

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.

seancorfield 2021-04-06T02:50:35.057700Z

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

seancorfield 2021-04-06T02:50:53.057900Z

Whereas I have to restart VS Code more often 🙂

seancorfield 2021-04-06T02:51:24.058100Z

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

apt 2021-04-06T02:53:08.058300Z

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 🙂

seancorfield 2021-04-06T02:54:41.058500Z

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).

seancorfield 2021-04-06T02:56:26.058700Z

I have four REPLs running on my desktop I think.

apt 2021-04-06T03:01:50.058900Z

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

apt 2021-04-06T03:02:01.059100Z

(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.)

seancorfield 2021-04-06T03:05:24.059300Z

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

seancorfield 2021-04-06T03:07:05.059500Z

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 @andre.peric

apt 2021-04-06T03:08:34.059800Z

nice , will have a look at it.

mauricio.szabo 2021-04-05T22:18:26.054300Z

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

mauricio.szabo 2021-04-05T22:18:39.054700Z

Version 1.55.0-1617120720

🤣 2
mauricio.szabo 2021-04-05T22:40:52.055200Z

Well, reported the bug 😄 https://github.com/microsoft/vscode/issues/120593