nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
Eugen 2020-05-03T09:36:16.053900Z

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) ?

Eugen 2020-05-04T09:21:01.066Z

thanks, it's very helpful

Eugen 2020-05-04T09:21:12.066200Z

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

Eugen 2020-05-04T09:21:50.066500Z

I've gone with basic socket based nRepl

Eugen 2020-05-04T09:22:09.066700Z

it can be started / stopped at will

Eugen 2020-05-04T09:22:51.066900Z

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

Eugen 2020-05-04T09:24:44.067100Z

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

Eugen 2020-05-03T09:38:09.055800Z

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

Eugen 2020-05-03T09:38:54.056700Z

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

Eugen 2020-05-03T09:43:09.057900Z

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

Eugen 2020-05-03T10:04:48.059100Z

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

shen 2020-05-03T20:19:21.059300Z

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

shen 2020-05-03T20:20:41.059500Z

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.

shen 2020-05-03T20:24:00.059800Z

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

shen 2020-05-03T20:24:23.060Z

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

shen 2020-05-03T20:24:35.060200Z

ditto for brower based clients

shen 2020-05-03T20:26:22.060400Z

Here's a list of clients: https://nrepl.org/nrepl/0.7.0/usage/clients.html

shen 2020-05-03T20:26:44.060600Z

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

shen 2020-05-03T20:26:53.060800Z

but compatibility should still be good

2020-05-03T20:45:04.063Z

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 ^^?

bozhidar 2020-05-04T07:44:38.065400Z

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.

bozhidar 2020-05-04T07:45:05.065600Z

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

2020-05-04T08:14:44.065800Z

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

shen 2020-05-04T09:55:49.067800Z

what client are you using to connect to nREPL?

shen 2020-05-04T09:56:11.068Z

this feels like a client-space feature

2020-05-04T10:19:51.068200Z

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.

2020-05-04T10:21:39.068400Z

My experience with nREPL is very limited tho

shen 2020-05-04T10:22:08.068600Z

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

shen 2020-05-04T10:22:29.068800Z

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

shen 2020-05-04T10:24:33.069Z

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

shen 2020-05-04T10:24:48.069200Z

and not fulfil it directly

2020-05-04T10:27:55.069400Z

I’ll try convincing lein once more

2020-05-04T11:00:57.071100Z

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

shen 2020-05-04T11:12:31.071300Z

pleasure

shen 2020-05-05T22:04:37.075700Z

hey. just saw the issue you posted in nREPL

shen 2020-05-05T22:04:49.075900Z

I just checked what you are trying to do

shen 2020-05-05T22:05:19.076100Z

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

shen 2020-05-05T22:05:57.076300Z

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

2020-05-05T22:31:10.078100Z

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

2020-05-06T07:05:06.081100Z

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.

shen 2020-05-06T10:16:03.081300Z

ah right. that makes sense.

shen 2020-05-06T10:18:05.081500Z

will respond in the gh issue

👍 1
shen 2020-05-06T11:45:00.081800Z

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

shen 2020-05-06T11:45:08.082Z

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

2020-05-06T13:14:43.082500Z

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

2020-05-06T13:16:00.082800Z

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 🙂

shen 2020-05-06T15:48:31.083100Z

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

shen 2020-05-06T15:49:28.083300Z

(that's the cursive author)

dominicm 2020-05-03T20:49:30.064100Z

There's no configuration flag for it

dominicm 2020-05-03T20:49:39.064500Z

I think lein uses a custom middleware

bozhidar 2020-05-04T07:43:43.065200Z

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

shen 2020-05-04T09:52:54.067300Z

ha. does look like a custom middleware

bozhidar 2020-05-05T11:42:01.074400Z

Indeed! I stand corrected then. 😄

bozhidar 2020-05-05T11:42:46.074600Z

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.

2020-05-05T17:04:56.074800Z

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

2020-05-05T17:07:47.075100Z

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

2020-05-05T17:43:02.075300Z

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

2020-05-03T20:59:22.064700Z

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?

dominicm 2020-05-03T21:53:58.064900Z

Yes

👍 1