classpath
classpath copied to clipboard
install-priority-loader! does not work if clojure.tools.namespace.repl/refresh has been called.
I have two lines in user.clj to switch between my development and test environment when running tests in the repl:
(comment (licp/install-priority-loader! ["env/test" "env/test/resources"]))
(comment (licp/install-priority-loader! ["env/development" "env/development/resources"]))
If I then (require 'foo :reload) the relevant namespaces, I can switch priority between env/test and env/development indefinitely.
However, if at any point in the repl session I call clojure.tools.namespace.repl/refresh, the above code stops having this effect (and whichever env was higher priority before calling refresh stays higher priority).
Strangely, I've noticed that if I run refresh-all at least once before I run refresh, this issue doesn't occur.
Related issue: https://github.com/lambdaisland/kaocha/issues/330
I suggest inspecting classpath-chain and classloader-chain to debug what's going on.
Thanks, I don't see any obvious differences in output if I inspect those with and without the initial refresh-all. Is there a way of getting more info on what's actually going on in the classloader objects for lines like these?
#object[clojure.lang.DynamicClassLoader 0x4163e0fc "clojure.lang.DynamicClassLoader@4163e0fc"]
[clojure.lang.DynamicClassLoader@ec1373a ()]
Calling clojure.tools.namespace.repl/set-refresh-dirs in user.clj seems to fix this issue for me.