Fork me on GitHub
#cider
<
2021-10-12
>
Sampo Toiva07:10:10

Hi, any idea on what might cause an error:

Error running hook "clj-refactor-mode" because: (error Given parent class xref-location is not a class)
When opening a .clj file. More specific stacktrace points that this comes from cider :
Debugger entered--Lisp error: (error "Given parent class xref-location is not a class")
  error("Given parent class %S is not a class" xref-location)
  eieio-defclass-internal(xref-etags-location (xref-location) ((tag-info :type list :initarg :tag-info) (file :type string :initarg :file :reader xref-location-group)) (:documentation "Location of an etags tag."))
 ...
  require(etags)
 ...
  require(cider-common)
 ...
  require(cider-client)
 ...
  require(cider)
 ...
  clj-refactor-mode()
 ...

Sampo Toiva09:10:48

Allright, recompiled everything and now I'm getting: Symbol's value as variable is void: xref-etags-location

vemv10:10:36

Not really familiar with this stuff but either a require is missing or xref-etags-location does in fact not exist anymore? Sadly breaking changes aren't uncommon in .el libs 😞

Sampo Toiva10:10:45

Ok figured it out. I need to investigate a bit more but I'll write here a thorough explanation soon.

Sampo Toiva10:10:17

Ok, cider-common.el requires etags here: https://github.com/clojure-emacs/cider/blob/master/cider-common.el#L31 That's required only for function find-tag-marker-ring (https://github.com/clojure-emacs/cider/blob/master/cider-common.el#L154). That's obsolete since emacs 25.1 , but I think finally emacs 28 removed it completely. The correct way should be, to my knowledge, to first (require 'xref) and then use xref-push-marker-stack instead of find-tag-marker-ring. Here's a similar issue in haskell-mode: https://github.com/haskell/haskell-mode/issues/459

vemv10:10:53

Sounds reasonable! GH issue appreciated

Sampo Toiva10:10:43

Yep, writing one.

Sampo Toiva10:10:28

I patched my own cider with those changes and things seem to work.

vemv17:10:38

it lgtm but that's not my area of expertise either. Let's see if a reviewer pops up else feel free to bump the thread over gh.

Sampo Toiva18:10:21

Not my area of expertise either 😉 However, the code is essentially identical: • find-tag-marker-ring was a variable alias for xref--marker-ringxref-push-marker-stack is implemented as:

(defun xref-push-marker-stack (&optional m)
  "Add point M (defaults to `point-marker') to the marker stack."
  (ring-insert xref--marker-ring (or m (point-marker))))
• That's identical with the old code in cider-common (minus the optional m param)

👌 1
👏 1
plexus08:10:32

does cljs-repl-type 'shadow actually work for people? I don't remember it ever working, and have always had a custom setup for it. This is what I get:

;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :main) (shadow/nrepl-select :main))
;;
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
shadow-cljs has not been started yet!
In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it.
If you have a shadow-cljs server or watch running then you are not connected to that process.

plexus08:10:41

it also seems there's no built-in support for adding the shadow-cljs middleware? I feel like a jack-in-clj&cljs should just work at this point but it seems some key pieces are missing...

plexus08:10:02

I should mention I'm using clojure-cli to start the process

dpsutton12:10:15

It does. I’m guessing you are using deps edn with it?

dpsutton12:10:57

There’s an issue that explains how the middleware can end up there.

plexus13:10:13

you are saying it is supposed to work? because I don't find any mention in the cider code base of the shadow middleware

plexus13:10:52

Got it to work by adding this:

(add-to-list 'cider-jack-in-nrepl-middlewares (list "shadow.cljs.devtools.server.nrepl/middleware"
                                                    :predicate #'cider--shadow-cljs-repl-p))

(defun cider--shadow-cljs-repl-p (_spec)
  (eq 'shadow cider-default-cljs-repl))
and adding a call to (shadow.cljs.devtools.server/start!) to the cljs repl init code. It seems the current code assumes that when cljs-repl-type is shadow, that your cider-preferred-build-tool is also shadow

dpsutton13:10:05

ah that would be problematic