Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cider-xref-fn-refs "invalid namespace" error #135

Closed
scramjet opened this issue Nov 20, 2019 · 3 comments · Fixed by #136
Closed

cider-xref-fn-refs "invalid namespace" error #135

scramjet opened this issue Nov 20, 2019 · 3 comments · Fixed by #136

Comments

@scramjet
Copy link

Hello, I'm trying to use the cider-xref-fn-refs function to scan for uses of a function, and getting the error below.

There is indeed no "basis" namespace (but there are a number sub-namespaces inside it). I do use namespaced keys in various places like ":basis/version", etc, so wondering if this might be the source of the error.

I'm happy to try to debug this further, if you can point me in the right direction.

Cheers,

Matt.

;; CIDER 0.23.0 (Lima), nREPL 0.6.0
;; Clojure 1.10.0, Java 12.0.1

1. Unhandled java.lang.IllegalArgumentException
   No such namespace: basis

                  Var.java:  146  clojure.lang.Var/find
                  core.clj: 2020  clojure.core/find-var
                  core.clj: 2015  clojure.core/find-var
                  xref.clj:   13  cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/as-val
                  xref.clj:    8  cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/as-val
                  xref.clj:   21  cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/fn-deps
                  xref.clj:   16  cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/fn-deps
                  core.clj: 2755  clojure.core/map/fn
              LazySeq.java:   42  clojure.lang.LazySeq/sval
              LazySeq.java:   51  clojure.lang.LazySeq/seq
                 Cons.java:   39  clojure.lang.Cons/next
                   RT.java:  709  clojure.lang.RT/next
                  core.clj:   64  clojure.core/next
                  core.clj: 3079  clojure.core/zipmap
                  core.clj: 3071  clojure.core/zipmap
                  xref.clj:   52  cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/fn-refs
                  xref.clj:   44  cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/fn-refs
                  xref.clj:   22  cider.nrepl.middleware.xref/fn-refs-reply
                  xref.clj:   20  cider.nrepl.middleware.xref/fn-refs-reply
        error_handling.clj:  160  cider.nrepl.middleware.util.error-handling/eval6545/fn
              MultiFn.java:  234  clojure.lang.MultiFn/invoke
                  xref.clj:   29  cider.nrepl.middleware.xref/handle-xref
                  xref.clj:   28  cider.nrepl.middleware.xref/handle-xref
                  Var.java:  388  clojure.lang.Var/invoke
                 nrepl.clj:  466  cider.nrepl/wrap-xref/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  299  cider.nrepl/wrap-profile/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  243  cider.nrepl/wrap-macroexpand/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
    interruptible_eval.clj:  144  nrepl.middleware.interruptible-eval/interruptible-eval/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
               session.clj:  326  nrepl.middleware.session/add-stdin/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
             load_file.clj:   81  nrepl.middleware.load-file/wrap-load-file/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  199  cider.nrepl/wrap-inspect/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                caught.clj:   97  nrepl.middleware.caught/wrap-caught/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  437  cider.nrepl/wrap-tracker/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  136  cider.nrepl/wrap-debug/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  162  cider.nrepl/wrap-enlighten/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:   82  cider.nrepl/wrap-content-type/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 print.clj:  234  nrepl.middleware.print/wrap-print/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                 nrepl.clj:  290  cider.nrepl/wrap-out/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
               session.clj:  272  nrepl.middleware.session/session/fn
            middleware.clj:   16  nrepl.middleware/wrap-conj-descriptor/fn
                server.clj:   18  nrepl.server/handle*
                server.clj:   15  nrepl.server/handle*
                server.clj:   27  nrepl.server/handle/fn
                  core.clj: 2030  clojure.core/binding-conveyor-fn/fn
                  AFn.java:   18  clojure.lang.AFn/call
           FutureTask.java:  264  java.util.concurrent.FutureTask/run
   ThreadPoolExecutor.java: 1128  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  628  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  835  java.lang.Thread/run
@bbatsov
Copy link
Member

bbatsov commented Nov 21, 2019

I'm happy to try to debug this further, if you can point me in the right direction.

You can just invoke orchard.xref/fn-deps directly in a REPL and see what's wrong. Looking at the stacktrace it seems that the var resolution is failing. What exactly is the name of the var you're invoking this on?

@scramjet
Copy link
Author

The var is named systematic.doorkeeper.react.tasks/create-notif. (It's defined with Plumatic schema's defn with schema annotations, but other 'bare' defn's fail with the same error).

I can't see orchard.xref/fn-deps in the attached REPL. The orchard namespaces I can see are:

orchard.eldoc <n> 	orchard.info <n> 	orchard.inspect <n> 	orchard.java <n>
orchard.java.parser <n> 	orchard.meta <n> 	orchard.misc <n> 	orchard.namespace <n>
orchard.query <n> 	orchard.spec <n>

But, I can do this:

systematic.doorkeeper.react.tasks> (cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/fn-deps #'create-notif)
#{#'clojure.core/pr-str #'schema.core/fn-validator
  #'schema.utils/format* #'clojure.core/deref}

But of course using the same for fn-refs gives me the same error:

systematic.doorkeeper.react.tasks> (cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/fn-refs #'create-notif)
Execution error (IllegalArgumentException) at cider.nrepl.inlined-deps.orchard.v0v5v0.orchard.xref/as-val (xref.clj:13).
No such namespace: basis

@vemv vemv transferred this issue from clojure-emacs/cider Oct 5, 2021
@plexus
Copy link
Contributor

plexus commented Oct 11, 2021

Minimal repro:

(def xxx 'foo/bar)

(fn-refs #'str)
1. Unhandled java.lang.IllegalArgumentException
   No such namespace: foo

                  Var.java:  146  clojure.lang.Var/find
                  core.clj: 2020  clojure.core/find-var
                  core.clj: 2015  clojure.core/find-var
                  xref.clj:   13  orchard.xref/as-val

This happens because fn-refs and fn-deps both resolve the vars with as-val. This works if vars contain functions because then as-val is idempotent, but if the var contains a symbol as-val will try to look up the var with that name.

I'll make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants