Fork me on GitHub
#nrepl
<
2020-12-17
>
glenjamin13:12:15

👋 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

dave13:12:35

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

glenjamin13:12:56

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

borkdude14:12:49

@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

borkdude14:12:01

but this is possibly lower level than you would like

borkdude14:12:38

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

💡 3
dave14:12:30

wow, that's an awesome idea

glenjamin14:12:07

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

borkdude14:12:58

@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

glenjamin14:12:01

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

flowthing14:12:46

@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.

thanks 3
borkdude15:12:55

@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 :)

borkdude15:12:55

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

😄 3
glenjamin15:12:20

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

borkdude15:12:56

At least this works if I close the REPL:

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

borkdude15:12:36

ehm... it works!

borkdude15:12:10

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

borkdude15:12:08

$ ./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!

borkdude15:12:28

size of reply binary: 39867048

glenjamin15:12:46

oh wow, nice one!

borkdude15:12:34

@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.

glenjamin15:12:04

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

borkdude16:12:59

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)

borkdude16:12:16

@glenjamin I invited you to the repo

borkdude16:12:23

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

glenjamin16:12:45

perfect, thanks

glenjamin16:12:48

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

borkdude16:12:48

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

borkdude16:12:32

I invited your colleague

glenjamin16:12:18

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 😄