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) ?
thanks, it's very helpful
I did manage to do what I was aiming for https://github.com/netdava/ofbiz-clojure-repl
I've gone with basic socket based nRepl
it can be started / stopped at will
authentication is an issue - since there are no OOTB options out there
I think drawbridh over websocket + Oauth2 / OpenID connect would be nice at some point
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
ideally this should be usable from the browser but connecting from ide would be ok too.
for whom it might concern: just found https://github.com/tstout/spring-repl which is a nice start, please share how you use it
also found https://libraries.io/github/matlux/jvm-breakglass , is there a browser IDE for clojure /nrepl?
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
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.
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
I'm sure standalone tools exist, but that's not a common way to use nREPL, so doubt they are too well developed
ditto for brower based clients
Here's a list of clients: https://nrepl.org/nrepl/0.7.0/usage/clients.html
not all of them are in active development, and some are very dead though
but compatibility should still be good
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 ^^?
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.
It’s just a matter of setting *ns*
for the initial nREPL session manually.
I’ll create an issue somewhere today ^^, thanks
what client are you using to connect to nREPL?
this feels like a client-space feature
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.
My experience with nREPL is very limited tho
think if you can configure it in lein, do that rather
fwiw, I use user.clj
as the maintenance ns for this reason
the general approach is that nREPL is mainly there to enable client-tools to serve enduser requirements
and not fulfil it directly
I’ll try convincing lein once more
check this line in the example project? https://github.com/technomancy/leiningen/blob/145ba54eb0a5fc099380ad6feb04688a2fca9173/sample.project.clj#L373
Yeah I think I tried that, but I wasn’t too awake anymore, so I probably did something wrong ^^. Thanks for your help!
pleasure
hey. just saw the issue you posted in nREPL
I just checked what you are trying to do
did you place the :init-ns
inside of :repl-options
?
i.e. this :repl-options {:init-ns your.namespace}
inside of project.clj
Yes, it works for lein repl
but not for lein repl :connect ...
.
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.
ah right. that makes sense.
will respond in the gh issue
just want to check: do you have a workaround right now?
release cycle for nrepl/lein etc. is not that fast
yeah, just swapping ns manually. Usually connecting with cursive so thats not too much of a hassle!
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 🙂
you can probably also ask Ian to see if he'll add the feature to cursive
(that's the cursive author)
There's no configuration flag for it
I think lein uses a custom middleware
I don’t think that’s the case, actually. If I recall correctly it was just setting *ns*
manually.
ha. does look like a custom middleware
Indeed! I stand corrected then. 😄
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.
I’ll start a discussion on that in a GitHub issue then ^^
also for traceability if it ends up being something that is not desirable for some reason
Lets continue these two threads here: https://github.com/nrepl/nrepl/issues/186 ^^
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?
Yes