Resetting a Clojure REPL after switching branches
When developing in Clojure I use reloaded.repl to regularly reset the REPL state.
However, if you’ve just switched to a new git branch and files that were present on the previous branch are no longer present then a
(reset) will throw a
To fix this we need to reset the list of files that
clojure.tools.namespace is tracking:
(alter-var-root #'clojure.tools.namespace.repl/refresh-tracker (fn [_ ] (clojure.tools.namespace.track/tracker))) (reloaded.repl/reset)
I’ve set up a keybinding for this in my editor and use it each time I want to reset the REPL state.