unrepl

discussing specification of an edn-based repl and its implementations.
nblumoe 2018-01-17T08:50:40.000344Z

Hey folks. :spock-hand: Is it supported to upgrade to an UNREPL via -e, or -i options of the clojure command (we are using the blob from the unrepl github repo for now)? It seems to upgrade the REPL correctly, but we we are facing issues when trying to shut down the process (process start and killing handled via the conch library). Or is the intended use to only upgrade via a socket?

cgrand 2018-01-17T08:55:59.000364Z

Hi @nblumoe, good question. I sometimes do cat resources/unrepl/blob.clj - | clojure to test.

nblumoe 2018-01-17T09:00:22.000053Z

I see, I can try that. But an upgrade like that would not result in upgraded REPLs on new socket connections, right?

cgrand 2018-01-17T09:01:21.000104Z

Right. Tell me more about what you are trying to achieve

nblumoe 2018-01-17T09:05:41.000347Z

We need to spawn multiple UNREPLs on a single host. By using 0 as the port, the port handling can be done by clojure itself. Of course we still need to the port to be able to connect to it and it can be retrieved in the REPL via (.getLocalPort (get-in @#'clojure.core.server/servers ["repl" :socket])). Already did this with a non-upgraded REPL via stdout and then later upgraded to UNREPL via socket. But we had the idea of doing the UNREPL upgrade as early as possible, so even before retrieving the port and have the socket port already in an UNREPL message.

nblumoe 2018-01-17T09:06:49.000122Z

Funny thing now is, that it kinda of works already. But when trying to stop the process via the conch lib, this fails when upgraded the REPL via -e or -i options…

nblumoe 2018-01-17T09:07:24.000491Z

(the lib just does (.destroy process) in the end)

cgrand 2018-01-17T09:14:28.000594Z

Do you use stdout for anything else?

cgrand 2018-01-17T09:18:36.000357Z

ok, re-read your message. So basically you want two things: 1/ know the port 2/ have the socket be already an unrepl connection without further upgrade Right?

cgrand 2018-01-17T09:21:19.000468Z

The 2/ rises a number of questions: • do you want one session per socket • aren’t you going to use auxillary connections?

nblumoe 2018-01-17T09:21:31.000324Z

Yes and be able to stop the process! :)

cgrand 2018-01-17T09:22:07.000171Z

May I ask why you “need to spawn multiple UNREPLs on a single host.“?

nblumoe 2018-01-17T09:25:11.000222Z

Yeah, kill from the CLI works for me too. But not killing it from within Clojure code that spawned the process.

nblumoe 2018-01-17T09:25:59.000515Z

We need to spawn multiple UNREPLs to create isolated environments in which we can run Clojure code (for nextjournal)

cgrand 2018-01-17T09:26:01.000111Z

Thats’s weird. Do you close stdin/stdout prior to killing?

cgrand 2018-01-17T09:28:13.000337Z

unrepl doesn’t provide isolation, namespaces are shared

nblumoe 2018-01-17T09:30:01.000621Z

Oh sorry. That was maybe misleading. I actually mean spawning multiple Socket REPLs, each one upgraded to an UNREPL.

cgrand 2018-01-17T09:32:00.000076Z

so nextjournal backend (a part of) is an unrepl client, right?

nblumoe 2018-01-17T09:33:51.000277Z

I just tried closing all streams (in, out, err) on the process manually before calling .destroy, did not change anything

nblumoe 2018-01-17T09:34:37.000060Z

Yes, @ backend + unrepl-client

cgrand 2018-01-17T09:36:31.000367Z

if you are going to use sideloading or a tooling connection I recommend against putting new sockets connectsion directly in unrepl mode (granted actually it may work because of the way further upgrades are handled but I’m not happy with this behaviour and may revisit it — and break it)

cgrand 2018-01-17T09:38:17.000484Z

The cost that you want to avoid is to send the blob for each socket, right?

nblumoe 2018-01-17T09:40:30.000317Z

Well, primarily I would like to avoid to first have to process normal REPL stdout messages (to retrieve the port) and then switch to working with UNREPL messages.

nblumoe 2018-01-17T09:41:49.000391Z

When passing the blob to clojure, the very first thing I get on the output, is the UNREPL :hello. It would be quite convenient being able to work with this.

cgrand 2018-01-17T09:43:08.000441Z

> Well, primarily I would like to avoid to first have to process normal REPL stdout messages (to retrieve the port) and then switch to working with UNREPL messages. But you are not doing to do further interaction on stdout, right?

nblumoe 2018-01-17T09:44:15.000166Z

That is correct

cgrand 2018-01-17T09:48:02.000069Z

clojure -e “(prn (some-> (get-in @#’clojure.core.server/servers [\“repl\” :socket]) .getLocalPort)) (read)”

👍 1
nblumoe 2018-01-17T09:48:26.000285Z

That’s what I just have done! 🙂

cgrand 2018-01-17T09:48:47.000314Z

so no repl output on tsdout

nblumoe 2018-01-17T09:50:01.000189Z

why the (read) in the end?

cgrand 2018-01-17T09:50:23.000632Z

to prevent exit

cgrand 2018-01-17T09:50:39.000474Z

(.wait (Object.)) if you prefer

nblumoe 2018-01-17T09:53:06.000371Z

Oh I see, would have used the -r flag. But your solution also avoids printing a prompt.

cgrand 2018-01-17T09:53:24.000370Z

yup

nblumoe 2018-01-17T09:56:41.000213Z

Cool, going to upgrade to UNREPL via socket then again. Regarding auxiliary connections and sessions per socket: Not sure yet, guess I need read about that first and refine a concept.

cgrand 2018-01-17T09:57:31.000176Z

do you plan coming to the hack-together day?

nblumoe 2018-01-17T10:00:22.000164Z

Is there another one? I was only aware of the last one, when you gave the talk at the meetup.

cgrand 2018-01-17T10:00:55.000176Z

ok there will be another on the friday before :clojureD

nblumoe 2018-01-17T10:02:32.000455Z

Cool, I missed that apparently. Is there some information available at some URL? 😄

cgrand 2018-01-17T10:02:51.000251Z

@pesterhazy ^^

nblumoe 2018-01-17T10:03:23.000222Z

Did you already get in touch with :clojureD people? We could do some advertisement for it if you would like us to.

cgrand 2018-01-17T10:04:47.000254Z

To summarize: somewhere in Berlin, send us (@volrath, @pesterhazy or me) a mail so that we know you are planning to come.

nblumoe 2018-01-17T10:05:38.000259Z

Do you have start and end times already? Would also propose it to others @ nextjournal

cgrand 2018-01-17T10:09:29.000238Z

10-18 iirc

cgrand 2018-01-17T10:10:28.000358Z

and we are open to suggestions for locations (as it may be a larger crowd)

nblumoe 2018-01-17T10:17:04.000419Z

How many people would you plan for?

cgrand 2018-01-17T10:22:08.000026Z

Let’s count: @pesterhazy, @volrath, me, Robert Marius Avram, Meikel Brandmeyer, @bozhidar (invited but I don’t know if he gave an answer) you and your folks 🙂 I most certainly have forgotten someone

cgrand 2018-01-17T10:22:35.000316Z

between 6 and 12?

mkvlr 2018-01-17T11:17:22.000052Z

@cgrand you’re welcome to do the hack day here at our (nextjournal) office at Schinkestr. 9

cgrand 2018-01-17T12:37:00.000095Z

@mkvlr thank you for the offer!

pesterhazy 2018-01-17T15:48:48.000562Z

@mkvlr nice!!

gcast 2018-01-17T20:03:17.000514Z

not sure if this is a known bug, but across several dependencies I get this error

[13] user=> (require '[gregor.core])
~ Unhandled Exception
              clojure.lang.ArityException: Wrong number of args (4) passed to: core/to-array
  clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (4) passed to: core/to-array, compiling:(gregor/core.clj:1:1)

                 AFn.java: 429 - clojure.lang.AFn/throwArity
                 AFn.java:  44 - clojure.lang.AFn/invoke
           NO_SOURCE_FILE: 342 - unrepl.replG__22$classloader$fn__269/invoke
                      nil:  -1 - unrepl.replG__22.proxy$java.lang.ClassLoader$ff19274a/findClass
         ClassLoader.java: 424 - java.lang.ClassLoader/loadClass
                      nil:  -1 - unrepl.replG__22.proxy$java.lang.ClassLoader$ff19274a/loadClass
         ClassLoader.java: 411 - java.lang.ClassLoader/loadClass
  DynamicClassLoader.java:  77 - clojure.lang.DynamicClassLoader/loadClass
         ClassLoader.java: 411 - java.lang.ClassLoader/loadClass
  DynamicClassLoader.java:  77 - clojure.lang.DynamicClassLoader/loadClass
         ClassLoader.java: 411 - java.lang.ClassLoader/loadClass
  DynamicClassLoader.java:  77 - clojure.lang.DynamicClassLoader/loadClass
         ClassLoader.java: 411 - java.lang.ClassLoader/loadClass
  DynamicClassLoader.java:  77 - clojure.lang.DynamicClassLoader/loadClass
         ClassLoader.java: 357 - java.lang.ClassLoader/loadClass
               Class.java:  -2 - java.lang.Class/forName0
               Class.java: 348 - java.lang.Class/forName
                  RT.java: 2183 - clojure.lang.RT/classForName
                  RT.java: 2196 - clojure.lang.RT/classForNameNonLoading
                 core.clj:   1 - gregor.core$eval1265$loading__7717__auto____1266/invoke
when side-loading

gcast 2018-01-17T20:23:51.000319Z

client is SPIRAL btw

dominicm 2018-01-17T21:46:47.000360Z

https://github.com/vvvvalvalval/scope-capture-nrepl somewhat good example of a reason to intercept the eval stages. It's not a game changer or anything, but it's something to consider.

cgrand 2018-01-17T23:20:42.000415Z

“Our stacktraces are bad because we don’t need them!”

👍 1
cgrand 2018-01-17T23:30:55.000181Z

@gcast huh? Ok a pair of square brackets are missing in unrepl.

gcast 2018-01-17T23:43:38.000348Z

@cgrand not sure if this helps, but side-loading works much of the time, but Ive received this error with about half a dozen distinct libraries.