Fork me on GitHub
#cider
<
2020-10-05
>
viebel13: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

viebel13: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]])

viebel14:10:08

Thank you @dpsutton

viebel14: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

viebel14:10:57

It doesn’t work

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)