Fork me on GitHub
#calva
<
2024-05-09
>
David Jaquay11:05:34

Is there a command that will run my project (lein) and give me a repl into it as it's running? My -main doesn't return, so running it myself from a new repl doesn't seem to be an option. (This seems really basic but I'm also really new to this...)

pez11:05:35

Sound like what you are looking for is the command: Calva: Start a Project REPL and Connect (aka Jack-In). Not sure what to do when your -main doesn’t return, but maybe connecting to the jack-in started repl, with something like lein repl :connect in a terminal, and run -main from there.

David Jaquay11:05:38

I've tried that, and it gives me the repl prompt, but doesn't run my -main , and if I do that myself (-main) , it doesn't return so I can't eval anything else (without quitting the app).

David Jaquay11:05:20

I kinda want to do a lein run and then connect to that, but that doesn't seem to work either.

pez11:05:07

> if I do that myself (-main) , it doesn’t return so I can’t eval anything else (without quitting the app). That’s why I suggested doing that from a terminal.

pez11:05:36

You can probably make lein run work too, if you embed the repl in your app: https://nrepl.org/nrepl/1.1/usage/server.html#embedding-nrepl

David Jaquay11:05:51

No, now I get what you're saying, and that's perfect!

🙏 1
pez11:05:08

Should also work with spawning of -main in a thread, come to think of it.

David Jaquay11:05:21

That's true too. Is that essentially what's going on anyway, where the lein run :connect is in its own thread?

pez11:05:21

Yes, it’s a matter of what you find most convenient. If you do it from the repl, you can bake it in as part of a https://calva.io/connect-sequences/. using the afterCLJReplJackInCode setting there. Then you would only need to run the jack-in command and you would get the REPL connected and -`main` running.

David Jaquay11:05:07

Very good, I'll take a look at that as well. Thanks for your help!

🙏 1