dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
2017-03-01T11:40:02.002693Z

fwiw, I had a file "out" lying around. Hence, directory could not be created. All fine now. Yay!

😵 1
qqq 2017-03-01T12:29:21.002696Z

@darwin: I have an on topic dirac question for once

qqq 2017-03-01T12:29:32.002697Z

the dirac browser repl running inside the chrome devtools

qqq 2017-03-01T12:29:37.002698Z

is there a way for emacs to somehow connect to it?

qqq 2017-03-01T12:29:53.002699Z

in other words, does dirac expose a nrepl?

2017-03-01T12:32:58.002700Z

nrepl has server and client(s), dirac implements nrepl client in chrome devtools

qqq 2017-03-01T12:33:16.002701Z

I'm looking at (dirac! :help)

qqq 2017-03-01T12:33:21.002702Z

how do I get the nrepl port number to connect to?

2017-03-01T12:33:59.002703Z

but it is more complicated, because nrepl talks over TCP/IP and devtools has only web sockets, that is why we have dirac agent which does a proxy/tunnel between those two

2017-03-01T12:35:23.002704Z

"how do I get the nrepl port number to connect to?” who is asking and where?

2017-03-01T12:36:00.002705Z

in general you created nrepl server and configured dirac to use it

2017-03-01T12:36:04.002706Z

so you should know its port

qqq 2017-03-01T12:37:17.002707Z

is my "nrepl server" started by 1) build.boot line (dirac :ids #{"main"}) or 2) when I fire up chrome canary ?

2017-03-01T12:39:57.002708Z

I don’t use boot, but it should be responsible for launching your nrepl server, at least my leiningen does

qqq 2017-03-01T12:40:30.002709Z

let me ponder more on this

2017-03-01T12:40:33.002710Z

also note that dirac has nrepl middleware which is a kinda nrepl server plugin, that has to be configured near that place

qqq 2017-03-01T12:40:55.002711Z

clearly I'm misunderstanding something, as truth = dirac devtools = nrepl client my previous thought: dirac devtools was a Nrepl SERVER that the web browser gui somehow connected to

2017-03-01T12:41:28.002712Z

also note that devtools is a web app, it cannot simply launch a server process on your machine

2017-03-01T12:41:45.002713Z

dirac devtools === nrepl-like client

qqq 2017-03-01T12:41:49.002714Z

I thought installing latest canary + running it with that long command ilne gave it special powers

qqq 2017-03-01T12:41:57.002715Z

thanks for pointing out mental errors

2017-03-01T12:42:08.002716Z

you should go through this document: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md

qqq 2017-03-01T12:42:08.002718Z

so if dirac devtools = nrepl like client

qqq 2017-03-01T12:42:43.002719Z

then it's 100% hopeless for me to go from emacs to send command to "dirac webtools ui" to ahve it 1) appear in the browser console and 2) execute in the browser console right? so even if I connected to the nrepl, it'd be two diffeerent client sessions

qqq 2017-03-01T12:43:15.002720Z

the ascii art in that readme is amazing

qqq 2017-03-01T12:44:18.002721Z

the diagrams are amazing; I'm going to underad that first, then I'll bother you at a later day

2017-03-01T12:45:17.002722Z

what you are trying to achieve is 100% possible, note that we have our code in nREPL server, in nREPL client (agent) and in devtools UI and all parts can communicate with each other

2017-03-01T12:45:53.002724Z

and I have done it with cursive: https://github.com/binaryage/dirac/blob/master/docs/integration.md

2017-03-01T12:46:21.002726Z

you are 95% there if you could reuse the same building blocks

2017-03-01T12:47:01.002728Z

I believe there is a chance it would work out-the-box with emacs, just nobody tried it before

qqq 2017-03-01T12:56:25.002729Z

Those diagrams are amazing. I think I get it now.

qqq 2017-03-01T12:56:38.002730Z

nrepl Server is at localhost::8230 dirac agent is at localhost::8231

2017-03-01T12:57:15.002731Z

and weasel connections are at localhost:8232 and up

qqq 2017-03-01T12:57:47.002732Z

so what I'm confused at is as follows -- do I just cider jack in 8230 ?

2017-03-01T12:58:09.002733Z

sorry, I don’t use cider

qqq 2017-03-01T12:58:17.002734Z

my confusion being I had to rip out all my other middleware in order to install dirac

qqq 2017-03-01T12:58:17.002735Z

hmm

qqq 2017-03-01T12:58:32.002736Z

besides using cursive, is there any other way for me to test connecting another repl and sending cmds over?

2017-03-01T12:59:07.002737Z

easily, leiningen and boot support running nrepl clients from command-line

2017-03-01T12:59:34.002738Z

at least leiningen for sure

qqq 2017-03-01T13:00:06.002739Z

I can run "boot repl -c" fine, but when I run (start-repl), I get all types of weird stack traces if all goes right, I should be able ot connect to a browser repl, and not just a clj repl right?

2017-03-01T13:00:34.002740Z

why do you run start-repl?

2017-03-01T13:01:02.002741Z

dirac has nothing to do with start-repl which tries to do the same job but differently

qqq 2017-03-01T13:01:28.002742Z

https://github.com/adzerk-oss/boot-cljs-repl <-- standard way I used to get browser repls

qqq 2017-03-01T13:01:30.002744Z

okay

qqq 2017-03-01T13:01:34.002745Z

let me figure out what I am doing wrong

2017-03-01T13:01:34.002746Z

when you connect to an nrepl server, you get a session, at that session is normal clojure

qqq 2017-03-01T13:02:12.002747Z

how do I go from "normal clojure" to "browser repl" ?

qqq 2017-03-01T13:02:15.002748Z

I can get normal clojure repl

2017-03-01T13:02:16.002749Z

again, I cannot help you with boot stuff, not sure what boot-cljs-repl is trying to do

2017-03-01T13:02:39.002750Z

but I assume it is trying to do their own weasel/browser-repl stuff

2017-03-01T13:02:47.002751Z

which has absolutely nothing to do with dirac

2017-03-01T13:02:54.002752Z

and you cannot expect it to work with dirac

qqq 2017-03-01T13:03:28.002753Z

okay

qqq 2017-03-01T13:03:33.002754Z

this is fasicnating

2017-03-01T13:03:44.002755Z

type (dirac! :status) and then (dirac! :ls) and post it here

2017-03-01T13:04:18.002756Z

in your clojure repl which you entered via boot repl -c

2017-03-01T13:04:41.002757Z

this repl connection should have access to dirac commands, because your nrepl server should have dirac middleware installed in it

qqq 2017-03-01T13:05:43.002759Z

amazing, did not know this repl had dirac! on it

2017-03-01T13:06:25.002760Z

you should understand it, if you fully understand this: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md

qqq 2017-03-01T13:06:33.002761Z

I'm going ot try (dirac! :join)

2017-03-01T13:06:48.002762Z

right! that should be your next step

qqq 2017-03-01T13:06:58.002763Z

1 sec

2017-03-01T13:07:12.002764Z

this is your “replacement” for (start-repl)

qqq 2017-03-01T13:08:16.002765Z

this gets me this: https://gist.github.com/anonymous/f7aca4aab15dc0653fa62079081308bf

qqq 2017-03-01T13:08:21.002766Z

but the alert hello does not appear

qqq 2017-03-01T13:08:40.002767Z

it's j/swindow

qqq 2017-03-01T13:08:40.002768Z

doh

2017-03-01T13:08:49.002769Z

you should read full article here https://github.com/binaryage/dirac/blob/master/docs/integration.md

2017-03-01T13:08:58.002770Z

see the last paragraphs

2017-03-01T13:09:22.002771Z

console output is a side-effect not a REPL command result

2017-03-01T13:09:44.002772Z

(+ 1 2) should work as expected

qqq 2017-03-01T13:10:30.002773Z

wow

qqq 2017-03-01T13:10:41.002774Z

(+ 1 2) ==> 3 did work, both in my terminal & in the browser devtool

qqq 2017-03-01T13:10:42.002775Z

this is insane

2017-03-01T13:11:47.002776Z

now try to connect to the same nrepl server from your emacs using normal nrepl client

2017-03-01T13:12:16.002777Z

not sure if it is called cider, but I think cider is much more than just an nrepl client implemented inside emacs

qqq 2017-03-01T13:12:38.002778Z

this is insane; I'm still in awe

2017-03-01T13:12:54.002779Z

if you want fullblown cider and dirac working together, cider will have to use another nrepl server, because cider and dirac middleware don’t like each other

qqq 2017-03-01T13:13:30.002780Z

there is one weird bug:

cljs.user=&gt;
at this place, if I type in (+ 2 3) we're good, if I just hit <enter> then my terminal freezes and I can't enter antything more at the terminal; not sure if this is a boot problem or what (perhaps it's sending NIL as input, and then waiting forever for something to print)

2017-03-01T13:14:02.002781Z

try it in lein repl :connect 8230

qqq 2017-03-01T13:15:22.002782Z

same issue

qqq 2017-03-01T13:15:28.002783Z

I suspect it is with powerlaces.boot-cljs-devtools

qqq 2017-03-01T13:15:33.002784Z

is that your package or someone else's ?

2017-03-01T13:15:47.002785Z

feel free to file a bug, I will look into that

2017-03-01T13:16:02.002786Z

have to go, now

qqq 2017-03-01T13:16:13.002787Z

thanks again for all your time

qqq 2017-03-01T13:16:14.002788Z

take care

2017-03-01T13:18:28.002789Z

While we are at it ... dirac middleware "complains" when it detects other middleware - i.e. cider. Is that serious or more like "there is something else - you may get away with it"?

qqq 2017-03-01T13:18:56.002790Z

in my experience, it's "choose me or choose cider"

qqq 2017-03-01T13:19:14.002791Z

and in my experience, it's worth giing up cider for

qqq 2017-03-01T13:19:22.002792Z

the debugging suppot for stack frames / printing locals is amazing

2017-03-01T13:20:32.002793Z

Ok, so I guess if one really needs other middleware, you should just spin up another nrepl service on another port.

qqq 2017-03-01T13:20:52.002794Z

the 'joined dirac session' is amazing

qqq 2017-03-01T13:21:00.002795Z

which unfortunately, probably doesn't like other middleware either

2017-03-01T13:36:34.002796Z

@deas it was explained here: https://github.com/binaryage/dirac/releases/tag/v1.1.4, if you don’t want to see that warning, I could add a config flag to disable it (in the next version)

2017-03-01T13:39:02.002798Z

@darwin A flag to disable it might be nice. In fact, I was wondering what to expect - especially wrt "popular" middleware like cider or clj-refactor.

2017-03-01T13:43:24.002800Z

I could also make this configurable: https://github.com/binaryage/dirac/blob/master/src/lib/dirac/lib/nrepl_tunnel.clj#L97 (this is how I detect expceted middleware, I ask for all supported operations, ciders adds bunch of new ones)

2017-03-01T13:45:18.002802Z

@darwin I think the solution should depend on what is to be expected. If 99% of the people see issues with cider, it may be best to simply spin up another nrepl service on another port.

qqq 2017-03-01T13:46:03.002803Z

@darwin: is there a debug option to tell dirac agent / nrepl server to be very very verbose? I want to see all msgs that are flying back and forth to see why it's hanging

2017-03-01T13:49:33.002805Z

Speaking of debugging: dirac.logging does not ship with the default jar. Might make sense to add it.

2017-03-01T14:06:40.002812Z

@darwin Doh! I hate being pointed to the faq. 🙂

2017-03-01T14:07:16.002813Z

🙂 np, there is a wall of text

qqq 2017-03-01T20:58:34.002818Z

@darwin: reporting that emacs / dirac repl works nicely with the following: 1. run inf-lisp process, with "boot repl -c" "(dirac! :join)" 2. define this function

(defun my-send-last ()
  (interactive)
  (comint-send-string
    (inferior-lisp-proc)
    (format "%s\r" (elisp--preceding-sexp))))
3. enjoy!

👍 1
2017-03-01T20:59:26.002819Z

@qqq nice! I’m glad to hear

qqq 2017-03-01T21:00:04.002820Z

@darwin: so I still haven't figured out the "(dirac :join) hangs if I hit enter twice in a repl" -- but if I only use the above, it (1) reads a sexp, and (2) sends precisely one \r, making it not hang

2017-03-01T21:00:36.002821Z

this info will be lost on slack, willing to update https://github.com/binaryage/dirac/blob/master/docs/integration.md? I would accept a PR with emacs-tips

2017-03-01T21:08:54.002823Z

@qqq I can confirm hang when hitting enter in nrepl client prompt, also dirac commands without parens are broken

2017-03-01T21:09:10.002824Z

the problem was likely introduced in https://github.com/binaryage/dirac/releases/tag/v1.1.4

qqq 2017-03-01T21:09:41.002828Z

I was reading about "debugging dirac" and it basically said "dirac is :optimizations :advanced; impossible to debug unless you ahve custom build"

qqq 2017-03-01T21:10:00.002829Z

@darwin: does this mean a 1.1.7 later today? 🙂

2017-03-01T21:10:33.002830Z

probably not, I’m going to release a next one on sunday as usual

2017-03-01T21:10:48.002831Z

this is not urgent, I think

qqq 2017-03-01T21:11:19.002832Z

fair enough; if I may ask, do you get paid to dev dirac, or is this all just personal project ?

2017-03-01T21:11:31.002833Z

personal

qqq 2017-03-01T21:12:12.002834Z

sunday sounds more than fair 🙂

2017-03-01T21:12:39.002835Z

sank too many hours into it, but it was fun 🙂

2017-03-01T22:22:33.002836Z

@deas actually the flag is already implemented: https://github.com/binaryage/dirac/blob/master/src/lib/dirac/lib/nrepl_tunnel.clj#L309

2017-03-01T22:23:47.002839Z

you should put :skip-paranoid-middleware-setup-check true into dirac agent options

2017-03-01T22:27:43.002840Z

a map with config options overrides can be passed into boot! as a parameter: https://github.com/binaryage/dirac-sample/blob/master/project.clj#L147 or you can use env var to override config: https://github.com/binaryage/dirac/blob/master/src/agent/dirac/agent/config.clj export DIRAC_AGENT__SKIP_PARANOID_MIDDLEWARE_SETUP_CHECK=true should work

👍 1