Fork me on GitHub
#cider
<
2020-10-05
>
Yehonathan Sharvit13:10:02

How we could get out of the “already refers to” situation in Cider? Quite often I am moving a function foo from ns a to ns b and when in ns c I am requiring (a :refer [foo] instead of (a :refer [foo]) , CIDER complains:

Unhandled java.lang.IllegalStateException
   foo already refers to: #'a/fo in
   namespace: c

Yehonathan Sharvit13:10:55

The only solution I found so far is to restart the REPL, which is a sacrilege!

dpsutton14:10:05

CIDER isn't complaining. Clojure is. If you can get away from using :refer you'll be fine. If not, there is ns-unmap.

dpsutton14:10:38

(ns-unmap 'c 'foo) and then (require [new-ns :refer [foo]])

Yehonathan Sharvit14:10:28

Is there a way in Cider (or in Clojure) to clear completly a ns?

dpsutton14:10:18

you could try cider-ns-reload after changing the namespace to the new location of foo. I don't know if that will work or not though

dpsutton14:10:32

ah bummer. i'm not aware of anything then

bozhidar16:10:58

I think you meant to say cider-ns-refresh.

bozhidar16:10:14

(that uses tools.namespace internally)