Fork me on GitHub
#cider
<
2018-10-22
>
vigilancetech06:10:02

Now I'm trying to take the shadow-cljs electron example code (https://github.com/shadow-cljs/examples/tree/master/electron) and connect to the main and renderer processes with emacs cider-connect-cljs (renderer first) then with cider-connect-sibling-cljs (main). When I do the renderer everything looks okay (other than a middleware mismatch error cuz I'm using the latest snapshot) but when I do the sibling it appears to give me the same repl and it has a bunch of errors:

...
;;
;; You can remove this message with the <M-x cider-repl-clear-help-banner> command.
;; You can disable it from appearing on start by setting
;; 'cider-repl-display-help-banner' to nil.
;; ======================================================================
shadow.user>
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings. To quit, type: :cljs/quit
[:selected :renderer]
WARNING: No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" (<stdin> at 1:55)
WARNING: Use of undeclared Var shadow/watch (<stdin> at 1:55)
WARNING: No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" (<stdin> at 1:76)
WARNING: Use of undeclared Var shadow/nrepl-select (<stdin> at 1:76)
cljs.user>
there's a 2nd repl buffer that is created with similar, but not quite exactly the same, results:
...
;;
;; You can remove this message with the <M-x cider-repl-clear-help-banner> command.
;; You can disable it from appearing on start by setting
;; 'cider-repl-display-help-banner' to nil.
;; ======================================================================
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.
shadow.user> TypeError: shadow.watch is not a function
    at eval (eval at <anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8), <anonymous>:4:8)
    at eval (eval at <anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8), <anonymous>:7:3)
    at file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.env.js:139:108)
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:827:46)
    at shadow$cljs$devtools$client$browser$handle_message (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:907:44)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.env.js:258:102)
    at WebSocket.<anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:1002:40)
shadow.user>
The 2nd repl's buffer status says it's only pending. The renderer repl doesn't initially have those (non-middleware) errors until after the sibling is created. From the terminal(s) the repls work perfectly. The renderer can do things like (js/alert "foo") and it works. The main issues an error when trying to do that (as it should because its only the launcher). Help!?!?

bozhidar10:10:35

Likely you don’t have refactor-nrepl in your deps. I guess if you don’t need it you can simply remove clj-refactor (or its warnings) and you’ll be just fine.

bozhidar10:10:06

For the other part of your problem you need someone like @thheller. 🙂

thheller10:10:49

@bozhidar I have no clue how emacs handles multiple CLJS repls but to me it looks like code intended for a CLJ REPL is getting sent to a CLJS REPL instead

bozhidar10:10:41

Ah, probably you’re right.

bozhidar10:10:47

> The 2nd repl’s buffer status says it’s only pending. The renderer repl doesn’t initially have those (non-middleware) errors until after the sibling is created.

bozhidar10:10:29

What’s the type of this REPL buffer?

thheller10:10:19

no clue. no idea what either cider-connect-cljs or cider-connect-sibling-cljs do

thheller10:10:41

shadow-cljs only provides a CLJ nrepl you can connect to directly. everything else is handled by the user.

bozhidar10:10:16

@thheller Recent changes. Those commands connect to a Clojure REPL and upgrade it automatically to cljs (the difference between the two is that one create a new session in CIDER, the other adds a connection to the existing session).

vigilancetech12:10:29

@bozhidar the 2nd buffer says its a "pending-cljs" type

thheller12:10:26

the first one is already broken too .. those warnings also mean that (shadow/watch ...) was eval'd in a CLJS context not CLJ

vigilancetech12:10:09

well, that was something I meant to ask you. Is the watch command correct on that example? shadow-cljs watch main renderer My understanding is there's supposed to be two processes. Does that create two? Like I said, from the terminal repl everything seems to be fine so I'm assuming so but just wondering. Shouldn't there be two nrepl's? It seems that both repls are connecting to the same port (at least from cider)

thheller12:10:51

there is only one JVM process and 2 build processes (threads) running inside that

thheller12:10:01

so yes only one nREPL which is CLJ and you can upgrade to CLJS

vigilancetech12:10:14

and so only one nrepl socket port

vigilancetech12:10:53

@bozhidar I have the [refactor-nrepl "2.4.0"] in the shadow-cljs.edn file (along with [cider/cider-nrepl "0.19.0-SNAPSHOT"])

vigilancetech12:10:39

so do(es) my issue(s) above constitute a bug I should report do you think?

vigilancetech13:10:37

what is the difference between shadow and shadow-select when selecting the session type?

vigilancetech13:10:29

when I just do cider-connect-cljs instead of cider-connect-sibling-cljs for the 2nd repl the pending repl issues this error instead of the namespace ones above: No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.

vigilancetech13:10:10

electron is running by executing electron . in the project folder