clj-on-windows

Ed 2025-03-10T13:36:19.920699Z

Hi. I'm trying to get a coworker set up on a project that works on linux, but he is using windows with wsl. We have a bash script that sets a few env vars and then runs npx shadow-cljs -A: ... which works fine on the linux box. However, on the windows machine, we can start the process and connect to it with Calva (something I also know very little about, I use Emacs/Cider so I thought it would be basically the same) and we can eval some code, but when starting the web server we get errors that suggest the env vars haven't been set. We ran (System/getenv "DATABASE_URL") and get nil back. We used ps aux to try and find the java process, and see only node processes in the list, which I find confusing. Do env vars work differently under WSL? Where can I find the java process? Anyone got any ideas?

seancorfield 2025-03-10T16:39:34.178549Z

Just to check: you're starting VS Code via the code command on the WSL (Linux) side, yes? And, no, env vars do not work differently on WSL. And you are connecting to that REPL, not jacking-in (and starting a new REPL from VS Code's env rather than your shell script).

Ed 2025-03-10T16:48:05.637379Z

Hello, and thanks for the help. We ran out of time today and had to pause till later in the week. We did try starting vs code from both inside a bash prompt and outside as a normal windows app. The description I posted above was from outside the WSL container, connecting to a jvm started from inside at a bash prompt. I was quite confused as to what was actually going on, partly because I couldn't see a java process in the ps list and the shell scrip we were running just sets some env vars and starts shadow-cljs via npx. We had installed openjdk and nodejs via apt.

Ed 2025-03-10T16:50:09.590449Z

When we tried running code . inside WSL and then running the shell script from inside vs code's terminal, and connecting calva we got what looked to me like networking issues - the process was up, but the output in the repl pane on the right said it couldn't connect.

Ed 2025-03-10T16:52:17.734849Z

We also tried jacking in and had no success there. I'm vaguely aware that you've said in the past that you connect rather than jack in. Is that the workflow that works for you? Do you start the jvm from a vs code prompt?

seancorfield 2025-03-10T17:04:32.320419Z

I start VS Code inside WSL (`code .`), start a Terminal inside VS Code (which is a bash WSL terminal), start a REPL there, and connect to it from VS Code. That survives a "reload" of VS Code (but not a restart), and I have an auto connect config in VS Code so after a reload, it automatically reconnects back to the same REPL (the terminal and the REPL in it survive the reload and also get "reconnected"). If you're getting connectivity problems, maybe your REPL server that you start isn't listening on 0.0.0.0, or maybe you have an old .nrepl-port file that isn't getting updated when you start Shadow? (file permissions preventing the update) If jack-in fails, how exactly does it fail. What do the Calva Says/Connection logs show?

Ed 2025-03-11T10:14:22.837139Z

We have :nrepl {:port 8200 :host "0.0.0.0"} in the shadow-cljs.edn file, and are typing in the port number. The jack in failed to connect in the same way, although from memory, I think that the repl process started but the client didn't connect. Is it possible that there's a windows firewall thing that's stopping the connection? How would I tell? I'm afraid I know nothing about windows (the last windows I used daily was windows 2000). I'm not sure I know what a "reload" in vs code is. Do you mean "it's an electron app, refresh the page"? How do you get hold of the Calva connection logs? As I said, I can't do any more diagnosis till later this week as the laptop and the person with the problem isn't available, but these sound useful. Thanks for the help.

seancorfield 2025-03-11T16:16:35.496099Z

VS Code has a command called "Developer: Reload Window" which you can run to update extensions to the latest version without restarting the editor (and losing your REPL). The command palette (`ctrl+shift+p`) lets you search for any commands. So ctrl+shift+p calva says will show you the command to display the Calva Says log, and from there you will see a drop-down with all the different log output options you can view. As for firewall etc, I don't think I changed anything from the defaults on my system -- I don't know enough about Windows admin for that 🙂 Everything I've done on Windows, I've learned from Bing (Copilot), TBH. Here's the only config for WSL that I know I've touched:

> cat /etc/wsl.conf
[network]
generateHosts = false
generateResolvConf = false
and
> cat /mnt/c/Users/seanc/.wslconfig
[wsl2]
memory=20GB
localhostForwarding=true
(in that last one, use whatever Windows username they have set up)