Fork me on GitHub
#nrepl
<
2020-05-03
>
Eugen09:05:16

hi, I'm new to clojure from Java and I would like to know how to embed nrepl in a production java app and what gui tools can I use to connect to it. what options are there for security (authentication) ?

shen20:05:21

the default transports are all socket based. What people typically do is to allow connection from local only, without security, then reply on SSH to provide security

shen20:05:41

there is https://github.com/nrepl/drawbridge, which gives access over https. don't think there's any built in security, but you are free to add your own there.

shen20:05:00

in term of GUI tools, the best bet are the ones built into the major clojure dev tools, e.g. Cursive for IntelliJ or Calva for VSCode

shen20:05:23

I'm sure standalone tools exist, but that's not a common way to use nREPL, so doubt they are too well developed

shen20:05:35

ditto for brower based clients

shen20:05:44

not all of them are in active development, and some are very dead though

shen20:05:53

but compatibility should still be good

Eugen09:05:01

thanks, it's very helpful

Eugen09:05:12

I did manage to do what I was aiming for https://github.com/netdava/ofbiz-clojure-repl

Eugen09:05:50

I've gone with basic socket based nRepl

Eugen09:05:09

it can be started / stopped at will

Eugen09:05:51

authentication is an issue - since there are no OOTB options out there

Eugen09:05:44

I think drawbridh over websocket + Oauth2 / OpenID connect would be nice at some point

Eugen09:05:09

I'm working on adopting clojure inside some projects and this is something that I would like to experiment with: • make the application start with nrepl • expose some 'context' that I can use to interact with the application runtime - like a spring application context

Eugen09:05:54

ideally this should be usable from the browser but connecting from ide would be ok too.

Eugen09:05:09

for whom it might concern: just found https://github.com/tstout/spring-repl which is a nice start, please share how you use it

Eugen10:05:48

also found https://libraries.io/github/matlux/jvm-breakglass , is there a browser IDE for clojure /nrepl?

Lennart Buit20:05:04

Hai. I have a bit of a question, I have this nrepl server, and I like to configure which ns you ‘drop into’ when you connect to it. Ala :init-ns in a leiningen project. Now I found https://github.com/lambdaisland/nrepl which is deprecated and suggests that you can configure this in nREPL. However, I can’t find out how 😞, can someone shine a bit of a light on that for me ^^?

bozhidar07:05:38

Feel free to submit a ticket for nREPL to add a command-line flag for this. I never needed it, so it didn’t cross my mind, but it’s easy to do.

bozhidar07:05:05

It’s just a matter of setting *ns* for the initial nREPL session manually.

Lennart Buit08:05:44

I’ll create an issue somewhere today ^^, thanks

shen09:05:49

what client are you using to connect to nREPL?

shen09:05:11

this feels like a client-space feature

Lennart Buit10:05:51

Using leiningen. I wonder tho, I wanted to configure it server side because the default user namespace has nothing, so I would say that it shouldn’t matter which client you use, you just want to drop in the ‘maintenance’ namespace so to say.

Lennart Buit10:05:39

My experience with nREPL is very limited tho

shen10:05:08

think if you can configure it in lein, do that rather

shen10:05:29

fwiw, I use user.clj as the maintenance ns for this reason

shen10:05:33

the general approach is that nREPL is mainly there to enable client-tools to serve enduser requirements

shen10:05:48

and not fulfil it directly

Lennart Buit10:05:55

I’ll try convincing lein once more

Lennart Buit11:05:57

Yeah I think I tried that, but I wasn’t too awake anymore, so I probably did something wrong ^^. Thanks for your help!

shen11:05:31

pleasure

shen22:05:37

hey. just saw the issue you posted in nREPL

shen22:05:49

I just checked what you are trying to do

shen22:05:19

did you place the :init-ns inside of :repl-options?

shen22:05:57

i.e. this :repl-options {:init-ns your.namespace} inside of project.clj

Lennart Buit22:05:10

Yes, it works for lein repl but not for lein repl :connect ....

Lennart Buit07:05:06

Oh there is a difference between connecting to the nrepl server started by leiningen (which does apply your init-ns), and connecting to one you started manually (e.g. with nrepl.server/start-server) which does not. That said, my applications don’t run through leiningen, so it would still be beneficial to me if either leiningen or nREPL allows ‘forcing’ an init-ns. I amended the issue with this information.

shen10:05:03

ah right. that makes sense.

shen10:05:05

will respond in the gh issue

👍 4
shen11:05:00

just want to check: do you have a workaround right now?

shen11:05:08

release cycle for nrepl/lein etc. is not that fast

Lennart Buit13:05:43

yeah, just swapping ns manually. Usually connecting with cursive so thats not too much of a hassle!

Lennart Buit13:05:00

Thank you for asking, and once more, if there is something I can assist in let me know! Given the constraints of being an nREPL newbie, ofcourse 🙂

shen15:05:31

you can probably also ask Ian to see if he'll add the feature to cursive

shen15:05:28

(that's the cursive author)

dominicm20:05:30

There's no configuration flag for it

dominicm20:05:39

I think lein uses a custom middleware

Lennart Buit20:05:22

Sorry, I don’t quite understand. Are you saying that there is no ‘easy’ way to configure it on the nrepl server side, but that leiningen uses a custom middleware to apply its init-ns when connecting to it?

bozhidar07:05:43

I don’t think that’s the case, actually. If I recall correctly it was just setting *ns* manually.

shen09:05:54

ha. does look like a custom middleware

bozhidar11:05:01

Indeed! I stand corrected then. 😄

bozhidar11:05:46

Well, I guess we really have to make this easier to set in nREPL directly - e.g. we can pass some optional initial ns to the server when starting or something along those lines.

Lennart Buit17:05:56

I’ll start a discussion on that in a GitHub issue then ^^

Lennart Buit17:05:47

also for traceability if it ends up being something that is not desirable for some reason

Lennart Buit17:05:02

Lets continue these two threads here: https://github.com/nrepl/nrepl/issues/186 ^^