cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
Yehonathan Sharvit 2020-10-05T13:52:02.093900Z

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 Sharvit 2020-10-05T13:52:55.094700Z

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

dpsutton 2020-10-05T14:08:05.095900Z

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

dpsutton 2020-10-05T14:08:38.096400Z

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

Yehonathan Sharvit 2020-10-05T14:20:08.096900Z

Thank you @dpsutton

1
Yehonathan Sharvit 2020-10-05T14:20:28.097300Z

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

dpsutton 2020-10-05T14:21:18.097800Z

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

Yehonathan Sharvit 2020-10-05T14:29:57.098100Z

It doesn’t work

dpsutton 2020-10-05T14:33:32.098400Z

ah bummer. i'm not aware of anything then

bozhidar 2020-10-05T16:43:58.099Z

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

bozhidar 2020-10-05T16:44:14.099300Z

(that uses tools.namespace internally)

bozhidar 2020-10-05T16:45:02.099500Z

There are some docs here https://docs.cider.mx/cider/0.26/usage/misc_features.html#reloading-code