Fork me on GitHub
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!


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


(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?


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


ah bummer. i'm not aware of anything then


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


(that uses tools.namespace internally)