Fork me on GitHub
#shadow-cljs
<
2020-10-13
>
MatD01:10:37

Hi. Is there a way for the test results to output the complete path of a failing test file? For example, suppose I have the following structure src + main ++ module1 +++ file.cljs + test ++ module1 +++ file_test.cljs when I have a failure, I get

FAIL in (my-test) (module1/file_test.cljs:31:13)
The problem is that I cannot click on the file path in the terminal and open the file directly, since it's missing the "src/test/" at the beginning

thheller08:10:36

not built-in no

πŸ‘ 3
jcf12:10:44

Hello again folks! Hope you're having a great day wherever you are. πŸ™‚ I've pushed things as far as I can without a working cljs REPL so have carved out sometime to get a Emacs/Cider-based nREPL connection working with shadow-cljs. The blocker right now is Cider trying to require cider.piggieback, which I've read shadow-cljs doesn't use at all. I'm using cider-jack-in-cljs with both :deps and :nrepl in my shadow-cljs.edn:

{:deps  {:aliases [:client]}
 :nrepl {:port 8777}
 ,,,}
I've tried adding Cider deps to my deps.edn even though Cider injects its deps/middleware for me:
/usr/bin/clojure -A:dev:test -Sdeps '{:deps {me.raynes/fs {:mvn/version "1.4.6"} compliment {:mvn/version "0.3.6"} com.cemerick/pomegranate {:mvn/version "0.4.0"} org.tcrawley/dynapath {:mvn/version "0.2.5"} nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
I haven't tried adding my client alias to my global CLI opts because I don't want browser-based dependencies being loaded in a server REPL but if that's the problem I can probably juggle things around. I've also read in a GitHub issue that use of :dependencies is recommended over use of :deps but that's on an old issue and I can't find any mention of such a recommendation in the shadow-cljs user guide. I keep reading that it's a simple as running cider-jack-in-cljs so I'm feeling a little dumb I guess. 🀷

jcf13:10:34

My .dir-locals.el contains this:

((nil
  (cider-clojure-cli-global-options . "-A:dev:test")
  (cider-default-cljs-repl . shadow-select)
  (cider-known-endpoints . (("localhost" "8777")))
  (cider-shadow-default-options . ":REDACTED")
  (cider-preferred-build-tool . clojure-cli)))

jcf13:10:16

{:clojure.main/message
 "Execution error at nrepl.cmdline/require-and-resolve (cmdline.clj:195).\nNo namespace: cider.piggieback found\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.Exception,
  :clojure.error/line 195,
  :clojure.error/cause "No namespace: cider.piggieback found",
  :clojure.error/symbol nrepl.cmdline/require-and-resolve,
  :clojure.error/source "cmdline.clj",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.Exception,
    :message "No namespace: cider.piggieback found",
    :at [clojure.core$the_ns invokeStatic "core.clj" 4162]}],
  :trace
  [[clojure.core$the_ns invokeStatic "core.clj" 4162]
   [clojure.core$ns_resolve invokeStatic "core.clj" 4369]
   [clojure.core$ns_resolve invokeStatic "core.clj" 4359]
   [clojure.core$ns_resolve invoke "core.clj" 4359]
   [nrepl.cmdline$require_and_resolve invokeStatic "cmdline.clj" 195]
   [nrepl.cmdline$require_and_resolve invoke "cmdline.clj" 185]
   [nrepl.cmdline$fn__3236 invokeStatic "cmdline.clj" 199]
   [nrepl.cmdline$fn__3236 invoke "cmdline.clj" 199]
   [clojure.core$map$fn__5862$fn__5863 invoke "core.clj" 2742]
   [clojure.core$map$fn__5862$fn__5863 invoke "core.clj" 2742]
   [clojure.lang.PersistentVector reduce "PersistentVector.java" 343]
   [clojure.core$transduce invokeStatic "core.clj" 6883]
   [clojure.core$into invokeStatic "core.clj" 6899]
   [clojure.core$into invoke "core.clj" 6887]
   [nrepl.cmdline$__GT_mw_list invokeStatic "cmdline.clj" 226]
   [nrepl.cmdline$__GT_mw_list invoke "cmdline.clj" 224]
   [nrepl.cmdline$build_handler invokeStatic "cmdline.clj" 235]
   [nrepl.cmdline$build_handler invoke "cmdline.clj" 228]
   [nrepl.cmdline$options__GT_handler invokeStatic "cmdline.clj" 304]
   [nrepl.cmdline$options__GT_handler invoke "cmdline.clj" 295]
   [nrepl.cmdline$server_opts invokeStatic "cmdline.clj" 352]
   [nrepl.cmdline$server_opts invoke "cmdline.clj" 340]
   [nrepl.cmdline$dispatch_commands invokeStatic "cmdline.clj" 443]
   [nrepl.cmdline$dispatch_commands invoke "cmdline.clj" 436]
   [nrepl.cmdline$_main invokeStatic "cmdline.clj" 459]
   [nrepl.cmdline$_main doInvoke "cmdline.clj" 454]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 665]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "No namespace: cider.piggieback found"}}
Stacktrace hidden in a file by Clojure. πŸ‘†

jcf13:10:36

I wish Clojure would write to stdout/stderr so I could redirect output myself. πŸ™‚

thheller13:10:36

I don't use emacs/cider so I don't have a clue how it works

thheller13:10:56

might be simpler to just connect to the REPL instead of jacking in

thheller13:10:24

ie. just run shadow-cljs server or so and then connect remotely to 8777 (however you do that I don't know though)

thheller13:10:05

the clojure call above doesn't seem to be using shadow-cljs

jcf13:10:14

Thanks for the pointers, @thheller. I tried connecting to the nREPL server running inside my shadow-cljs watch process but I get errors about middleware being missing. I've added the middleware to my deps.edn and get the same errors.

jcf13:10:36

;; Connected to nREPL server - 
;; CIDER 0.26.1 (Nesebar), nREPL 0.7.0
;; Clojure 1.10.1, Java 14.0.2
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;
;; ClojureScript REPL type: shadow-select
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :REDACTED))
;;
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)
To quit, type: :cljs/quit
;; => [:selected :REDACTED]WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0 and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user> 
cljs.user> 

thheller13:10:10

seems fine? just adjust the versions in deps.edn?

jcf13:10:29

Uno momento. I'll get the error from that. πŸ™‚

jcf13:10:13

I've added these deps to my :client alias:

cider/cider-nrepl             {:mvn/version "0.25.4"}
    refactor-nrepl/refactor-nrepl {:mvn/version "2.5.0"}
And now Cider tells me this:
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)

jcf13:10:49

I've checked my ~/.config/clojure/deps.edn and made sure there's no ~/.clojure/deps.edn. Where this snapshot version of Cider is coming from, I'm unsure.

jcf13:10:05

And why the explicit artefacts in my deps.edn are ignored…

jcf13:10:22

:aliases
 :client
  :extra-deps
   applied-science/js-interop    {:mvn/version "0.2.7"}
    cider/cider-nrepl             {:mvn/version "0.25.4"}

jcf13:10:45

Slack ditched a curly brace there. It's definitely in my deps.edn file. πŸ˜„

thheller13:10:28

might be a better question for #cider

jcf13:10:35

Hmm. Cider doesn't manage my dependencies when I connect a REPL but I guess they might have some vendored snapshot or some dependency resolution thing they're doing somewhere.

thheller13:10:19

I would expect it to respect deps.edn but I don't have a clue

thheller13:10:22

either way it is saying it requires 0.25.3 and you have 0.25.4 so that might be the problem too

thheller13:10:36

maybe try clojure -A:client -Stree or whatever the command was to list the tree. maybe that explains wheres its coming from

jcf13:10:33

I've asked the question over here too: https://clojurians.slack.com/archives/C0617A8PQ/p1602595230188700 Hopefully some of the lovely people over there are using my dream combo of Cider and shadow-cljs! πŸ™‚

thheller13:10:49

@jcf I just noticed from the command above it had /usr/bin/clojure -A:dev:test

thheller13:10:00

so that doesn't use the :client alias you setup?

jcf13:10:59

That's correct. In my shadow-cljs.edn file I have :deps {:aliases [:client]} … Do I need the initial invocation of Clojure to include :client too?

jcf13:10:34

That might get a little tricky as I don't always want to load up all my browser-based deps when I jack in. Maybe I can add those options to just the cljs opts.

thheller13:10:41

I cannot answer cider/emacs questions sorry. From the command above it did not invoke shadow-cljs at all so whatever is in shadow-cljs.edn also has no effect.

jcf13:10:53

Progress! πŸ’₯

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
DEPRECATED: Libs must be qualified, change compliment => compliment/compliment 
DEPRECATED: Libs must be qualified, change nrepl => nrepl/nrepl 
DEPRECATED: Libs must be qualified, change refactor-nrepl => refactor-nrepl/refactor-nrepl 
WARNING: When invoking clojure.main, use -M
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
nREPL server started on port 33897 on host localhost.localdomain - 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by dynapath.defaults$eval29666$fn__29667 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of dynapath.defaults$eval29666$fn__29667
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
;; Connected to nREPL server - 
;; CIDER 0.26.1 (Nesebar), nREPL 0.8.0
;; Clojure 1.10.1, Java 14.0.2
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;  Startup: /usr/bin/clojure -A:client:dev:test -Sdeps '{:deps {me.raynes/fs {:mvn/version "1.4.6"} compliment {:mvn/version "0.3.6"} com.cemerick/pomegranate {:mvn/version "0.4.0"} org.tcrawley/dynapath {:mvn/version "0.2.5"} nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
;;
;; ClojureScript REPL type: shadow-select
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :grocer))
;;
;; => :missing-nrepl-middlewareuser> 
user> 

jcf13:10:15

I've added :client to my CLI opts.

thheller13:10:13

ok now you are missing the shadow-cljs nrepl middleware

thheller13:10:47

dunno how you add that

jcf13:10:31

There's a cider-jack-in-cljs-nrepl-middlewares var that takes a list of strings from the looks of it.

jcf13:10:43

cider-jack-in-cljs-nrepl-middlewares is a variable defined in
cider.el.

Value
("cider.piggieback/wrap-cljs-repl")

Set

Documentation
List of Clojure variable names.

jcf13:10:44

I'm not sure if I need wrap-cljs-repl with shadow-cljs, right? I thought I read that shadow provides its own middleware.

thheller13:10:06

you can keep it but you don't need it yes

jcf13:10:38

Cool. Jacking in now. 🀞

jcf13:10:58

I think this exception is shadow-cljs letting me know that I'm not building anything?

Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
missing instance

jcf13:10:32

Not sure why an exception is thrown as that doesn't seem like an exceptional circumstance but maybe it's the way Cider's firing up the REPL internally.

thheller13:10:11

you are running in embedded mode so shadow-cljs isn't even started yet

thheller13:10:15

you need to start it

thheller13:10:14

it is an exception because the jack in likely wants to switch you to the shadow-cljs REPL which obviously can't work when shadow-cljs isn't even running

thheller13:10:02

I recommend connecting remotely ... doing all of this yourself is a lot of effort for basically no gain

jcf13:10:44

Okay, I'll stick with connecting Cider to shadow-cljs and forget about jacking in.

jcf13:10:01

I'll be starting from here:

WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)
To quit, type: :cljs/quit
;; => [:selected :grocer]No available JS runtime.
See > 
πŸ™‚

thheller13:10:09

looks like you got it. just open the browser with your code loaded. (assuming this is a browser build of course)

jcf13:10:14

That's awesome! I can connect to the browser and eval stuff like (js/alert "Hi, there!").

jcf13:10:29

Completion blows up quite spectacularly. πŸ˜„

jcf13:10:10

Yeah, I've stumbled across that issue today.

thheller13:10:10

you can turn that off to just get regular completion

jcf13:10:38

@thheller do you know how I turn that off to get regular completion?

jcf13:10:54

I can eval code but completion and eldoc are broken.

jcf13:10:09

Eldoc gives you the function signature in the bottom of the editor window, which is super handy.