Fork me on GitHub
#calva
<
2023-11-02
>
RK C01:11:23

I'm attempting to run "Fire up the Clojurescript Quickstart Browser REPL", but the browser does not launch and I see this in the calva-output pane ; Creating cljs repl session... ; Connecting cljs repl: deps.edn + ClojureScript built-in for browser... ; The Calva Connection Log might have more connection progress information. ; Execution error (BindException) at .PlainSocketImpl/socketBind (PlainSocketImpl.java:-2). Address already in use (Bind failed) ; Failed starting cljs repl ; Jack-in done. How do I debug this? I don't see any additional information in the Calva Connection Log. What port is the code trying to bind to? ps:I'm new to Clojure

RK C02:11:36

I'm running this on a Mac (Ventura)

RK C02:11:07

Looking into the temp folder, under out/clojure/browser/repl.cljs I see (goog-define HOST "localhost") (goog-define PORT 9000) changing it to 9001 does not help either.. I also changed it in repl.js. Still the same result. I do notice that the VPN ZScaler is listening on 9000. Not sure how to change the port to a different value.

pez09:11:13

Hmmm. I think the port may be hard coded as a default deep in there some how. Please file an issue about this. I will see if I can make Calva override the default. Meanwhile, to test some ClojureScript, the Node Quick Start should work. For testing with a browser app, you can check this template project out: https://github.com/PEZ/shadow-bare-bones It is a bit less basic, but also a bit more realistic, than Calva’s quick-start browser thing. Still very basic, though. And you’ll have an actual project to build from, which is a pretty big bonus. Please let me know how you fare. Here’s a similarly bare bones Clojure-only template: https://github.com/PEZ/clojure-get-started-mini The README there has some tips on resources for Clojure beginners. And I can truly recommend the #beginners channel on this slack. Super friendly and helpful people there!

RK C00:11:41

Thanks! I killed the ZScaler VPN and was able to launch the app. I will create an issue for this. I'm using this as a playground for code that I want to run in Ryan Robitaille's data-rabbit. I'll try the shadow-bare-bones!

pez06:11:13

Oh, I data-rabbit is on my bucket list. Then you really want to have a small project, because the Quick Start stuff is launched from your tmp folder and might get lost. If you prefer the minimalness of the CLJS quick starter, you can of course copy it out of the temp folder to wherever you have your projects. The project folder is everything before src/ in the path of the .cljs file that the quick starter opens. Then you open this project and use Calva’s Jack-in command to start and connect the repl, choosing the deps.edn + ClojureScript built-in for browser as the project type.

👍 1
mkarp10:11:28

Hey Peter @pez! Hope you’re doing great 👋 I have a question whether you’re aware of a small issue. Every time I try to connect to a REPL inside my team’s monorepo, I first select the project folder (I wish the most commonly used folders would be on the top, but that’s a minor one :)), and then I’m presented with “Please select a project type”. Every first time I open this list, I don’t see options like “deps.edn” for Clojure projects, and “shadow-cljs” for CLJS projects. If I open this list the second time, both of these options are present. I’m fairly used to this workflow now so it’s not a biggie, but I was encouraging a co-worker to use more REPL, and they were quite confused with this behaviour. So I’m curious if this is known, and maybe it’s a difficult issue to solve? Thanks!

pez11:11:06

Hey Misha, long time no see! I am doing great. Hoping the same for you. You shouldn’t wait with feedback like that about that you want the most commonly used project root first in that list. 😃 I think I’ve seen it suggested before, so we should create an issue for that and see what we can do without things getting complicated. As for the main issue. I don’t think we are aware of it. But tbh, I’m not sure I am following. I take it as that the project type menu has options, but lacks some options you expect to be there? So you need to retry and then list is correctly populated? If this is correctly understood by me, then I can’t reproduce it. I’m guessing we have a race condition. (It’s super ugly stateful stuff going on there, so would not surprise me.) Issue welcome! Making it two welcomed issues. 😃

mkarp14:11:16

> As for the main issue. I don’t think we are aware of it. But tbh, I’m not sure I am following. I take it as that the project type menu has options, but lacks some options you expect to be there? So you need to retry and then list is correctly populated? Yes, correct. I’ll share the video of the repro with you. Let me know if you need any more info! 🙏

pez10:11:57

I now am having a look at this but I can’t reproduce the problem, which makes it hard.

mkarp10:11:27

@pez Can you please try reproducing it after a cold start of vs code?

pez21:11:43

Looks like you’re using the old VSIX?

pez21:11:14

I think I see 22f698 there.

pez07:11:17

Can you test the VSIX ending with 7021xb97, @U9ES37CSZ? A VSIX is a zip package that VS Code (and VS too, I think) extensions come wrapped in. You install it from the VS Code Extensions pane, top meatballs menu -> Install from VSIX…. Sometimes when downloading them, they get renamed to .zip for some reason. Then VS Code won’t find it.

Ingy döt Net13:11:23

I removed the old .vsix files and tried again, but no joy yet:

mkarp13:11:52

@pez Thank you! I’ve also tried it, and can confirm the issue is not fixed 😞

Ingy döt Net13:11:28

Sorry for the confusion. I installed the wrong one again. Now I've installed calva-2.0.399-2334-populate-project-types-from-cold-7021cb97.zip and it is working as expected for my situation.

🙏 1
Ingy döt Net13:11:00

My repro is (on Linux): • ctl-shift P • Developer: Reload Window • ctl-shift P • Calva: Connect to a Running REPL Server in the Project

🙏 1
mkarp13:11:36

Just confirmed with @pez that the fix is working 👍 I wasn’t properly installing the vsix file facepalm

mkarp13:11:42

Thank you again @pez!

pez13:11:13

Thanks! I’ll be releasing right away.

Ingy döt Net13:11:38

@pez let me test once more...

Ingy döt Net13:11:02

Yep. Works. Thought I saw it not work again...

pez13:11:29

I think that the fact that I couldn’t reproduce it indicates that there is still some bug hiding in there. The whole thing is way more stateful than any Clojure coder wants to imagine. I wasn’t a Clojure coder when I wrote most of it… Haha. I think we will have to rewrite it considerably at some point soon.

leifericf11:11:59

I have a namespace that looks like this:

(ns server
  (:require  [org.httpkit.server :refer [run-server]]
             [stasis.core :refer [serve-pages]]
             [web :refer [pages]]))

(defonce server (atom nil))

(def app (serve-pages pages))

(defn stop []
  (when-some [s @server]
    (s :timeout 100)
    (reset! server nil)))

(defn start []
  (stop)
  (reset! server (-> #'app
                     (run-server {:port 8080}))))

(comment
  (start)
  (stop))
The start function is used to start a web server to preview my static website in the web browser while I work on my pages. After starting my REPL, I manually run the start function within the comment block. But is there a way to automatically run the start function every time the REPL starts?

leifericf11:11:12

Or maybe Calva can use an entry point like this? :thinking_face:

(ns main
  (:require [server :as s])
  (:gen-class))

(defn -main [& args]
  (s/start))
Which would typically be run from the terminal like so: clj -M -m main

pez11:11:52

You can create a https://calva.io/connect-sequences/ and configure afterCLJReplJackInCode there to require the server namespace and start the server. You can also do it in your entry point function, but that gets more complicated, because you will also need to make it start the nREPL server, which is done in Calva’s default entry point.

👀 1
pez11:11:45

dot-less top namespaces are discouraged, by the way. Something Java something something reason.

💡 2
leifericf11:11:18

Oh! I didn't know that. Thanks for the tip!