nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
glenjamin 2020-12-17T13:45:15.076300Z

👋 Does anyone know of a stand-alone nREPL client with similar featureset to REPL-y but with fewer/smaller dependencies? Ideally no JVM Readline and tab complete would be the main things I’m after

dave 2020-12-17T13:52:35.077Z

there is https://github.com/eraserhd/rep. i've never tried it, so i can't speak to what features it has, but maybe it fits the bill

glenjamin 2020-12-17T13:53:56.078Z

the scenario is i’ve got some tools we’re bundling into a container that will include connecting to an nrepl server, and i’d like to avoid having to include a whole jvm in there if possible

borkdude 2020-12-17T14:03:49.078400Z

@glenjamin it's possible to interact with an nREPL server from a bb script as well: https://book.babashka.org/#_interacting_with_an_nrepl_server

borkdude 2020-12-17T14:04:01.078900Z

but this is possibly lower level than you would like

borkdude 2020-12-17T14:04:38.079300Z

I'm using this on our CI to send commands to our production app, e.g. to clear caches

💡 1
glenjamin 2020-12-17T14:05:07.080Z

i suspect for now we’ll just bundle the usual lein repl stack, we did briefly try a graal compile and quickly abandoned it

borkdude 2020-12-17T14:07:58.081Z

@glenjamin if you would like to do without lein:

clojure -Sdeps '{:deps {reply/reply {:mvn/version "0.4.4"}}}' -M -m reply.main --attach localhost:1667

dave 2020-12-17T14:10:30.081200Z

wow, that's an awesome idea

glenjamin 2020-12-17T14:11:01.081800Z

cheers, we might try that, but i think once we’ve got the JVM in there then lein isn’t much on top

flowthing 2020-12-17T14:22:46.082300Z

@glenjamin There's a list of clients here: https://nrepl.org/nrepl/0.8/usage/clients.html#command-line-clients Not sure if any of them fit the bill.

1
borkdude 2020-12-17T15:00:55.083800Z

@glenjamin I have some success with reply on GraalVM, working around some issues in complete.core, reflection etc, etc.

$ ./reply --attach localhost:52612
REPL-y 0.4.4, nREPL 0.6.0
Clojure 1.10.0
OpenJDK 64-Bit Server VM 11.0.8+10
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (+ 1 2 3)
ExecutionException java.io.FileNotFoundException: Could not locate reply/parsing__init.class, reply/parsing.clj or reply/parsing.cljc on classpath.
This could potentially work. I'm willing to take a bet that if nothing comes out of it, you owe me nothing, but if I get it working, I do want to get paid for the hours I'm going to put in it :)

borkdude 2020-12-17T15:01:55.084600Z

One of the issues is that reply "complects" the in-process REPL with the client

😄 1
glenjamin 2020-12-17T15:02:20.085100Z

please don’t sink time into it on my account! This was only a “it’d be nice if my container was a few hundred MB smaller” idle thought

borkdude 2020-12-17T15:02:41.085300Z

:thumbsup:

borkdude 2020-12-17T15:03:56.085700Z

At least this works if I close the REPL:

$ ./reply --attach localhost:52612
ConnectException Connection refused (Connection refused)

borkdude 2020-12-17T15:09:36.086400Z

ehm... it works!

borkdude 2020-12-17T15:10:10.086600Z

user=> *clojure-version*
{:major 1, :minor 10, :incremental 0, :qualifier nil}

borkdude 2020-12-17T15:11:08.086800Z

$ ./reply --attach localhost:63307 <<< '(+ 1 2 3)'
REPL-y 0.4.4, nREPL 0.6.0
Clojure 1.10.0
OpenJDK 64-Bit Server VM 11.0.8+10
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (+ 1 2 3)
6
user=> Bye for now!

borkdude 2020-12-17T15:11:28.087Z

size of reply binary: 39867048

borkdude 2020-12-17T15:12:20.087300Z

^ @glenjamin...

glenjamin 2020-12-17T15:12:46.087500Z

oh wow, nice one!

borkdude 2020-12-17T15:58:34.088200Z

@glenjamin I just realized, I've been using CircleCI so much for my open source projects, I owe at least to publish this code, if you're interested.

glenjamin 2020-12-17T15:59:04.088400Z

that would be ace, i could imagine it would work as a PR to REPL-y?

borkdude 2020-12-17T16:00:59.088600Z

One of the issues is that some of the work is done in futures on the top-level. This causes trouble. So I just copied the source and fixed some of that. Some reflection issues. Some other hacks. It basically works if you run script/compile and set GRAALVM_HOME to 20.3.0 java 11. I'll make a private repo (which contains the hacky code, not meant for open source consumption yet)

borkdude 2020-12-17T16:06:16.088800Z

@glenjamin I invited you to the repo

borkdude 2020-12-17T16:12:23.089Z

if I should invite more of your colleagues, let me know

glenjamin 2020-12-17T16:16:45.089200Z

perfect, thanks

glenjamin 2020-12-17T16:17:48.089400Z

could you invite c2nes please? is this something you intend to keep private?

borkdude 2020-12-17T16:19:48.089600Z

depends. this is just scratch code for now, if I would open source it, it would need more testing

borkdude 2020-12-17T16:20:32.089800Z

I invited your colleague

glenjamin 2020-12-17T16:33:18.090Z

fair enough, i tend to throw a warning on the top and publish anyway - but my stuff isn’t nearly as popular or polished as your usual stuff - so my bar is much lower 😄