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 beginningnot built-in no
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. π€·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)))
{: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. πAll I can point you to is https://shadow-cljs.github.io/docs/UsersGuide.html#cider
I wish Clojure would write to stdout/stderr so I could redirect output myself. π
I don't use emacs/cider so I don't have a clue how it works
might be simpler to just connect to the REPL instead of jacking in
ie. just run shadow-cljs server
or so and then connect remotely to 8777 (however you do that I don't know though)
the clojure
call above doesn't seem to be using shadow-cljs
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.
;; Connected to nREPL server - <nrepl://localhost:8777>
;; 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>
seems fine? just adjust the versions in deps.edn
?
Uno momento. I'll get the error from that. π
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)
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.
And why the explicit artefacts in my deps.edn
are ignoredβ¦
:aliases
:client
:extra-deps
applied-science/js-interop {:mvn/version "0.2.7"}
cider/cider-nrepl {:mvn/version "0.25.4"}
might be a better question for #cider
Slack ditched a curly brace there. It's definitely in my deps.edn
file. π
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.
I would expect it to respect deps.edn but I don't have a clue
either way it is saying it requires 0.25.3
and you have 0.25.4
so that might be the problem too
maybe try clojure -A:client -Stree
or whatever the command was to list the tree. maybe that explains wheres its coming from
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! π
@jcf I just noticed from the command above it had /usr/bin/clojure -A:dev:test
so that doesn't use the :client
alias you setup?
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?
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.
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.
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 - <nrepl://localhost.localdomain:33897>
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 - <nrepl://localhost:33897>
;; 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>
I've added :client
to my CLI opts.
ok now you are missing the shadow-cljs nrepl middleware
https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server
dunno how you add that
There's a cider-jack-in-cljs-nrepl-middlewares
var that takes a list of strings from the looks of it.
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.
I'm not sure if I need wrap-cljs-repl
with shadow-cljs, right? I thought I read that shadow provides its own middleware.
you can keep it but you don't need it yes
Cool. Jacking in now. π€
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
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.
you are running in embedded mode so shadow-cljs isn't even started yet
you need to start it
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
I recommend connecting remotely ... doing all of this yourself is a lot of effort for basically no gain
Okay, I'll stick with connecting Cider to shadow-cljs and forget about jacking in.
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 <https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshootingshadow.user>>
πlooks like you got it. just open the browser with your code loaded. (assuming this is a browser build of course)
That's awesome! I can connect to the browser and eval stuff like (js/alert "Hi, there!")
.
Completion blows up quite spectacularly. π
thats likely https://github.com/rksm/clj-suitable/issues/15
Yeah, I've stumbled across that issue today.
you can turn that off to just get regular completion
@thheller do you know how I turn that off to get regular completion?
I can eval code but completion and eldoc are broken.
Eldoc gives you the function signature in the bottom of the editor window, which is super handy.
Found something here: https://github.com/clojure-emacs/cider/issues/2808#issuecomment-620382450