classpath icon indicating copy to clipboard operation
classpath copied to clipboard

install-priority-loader! does not work if clojure.tools.namespace.repl/refresh has been called.

Open AlexChalk opened this issue 2 years ago • 2 comments
trafficstars

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

AlexChalk avatar Jun 14 '23 18:06 AlexChalk

I suggest inspecting classpath-chain and classloader-chain to debug what's going on.

plexus avatar Jun 15 '23 07:06 plexus

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 ()]

AlexChalk avatar Jun 15 '23 14:06 AlexChalk

Calling clojure.tools.namespace.repl/set-refresh-dirs in user.clj seems to fix this issue for me.

AlexChalk avatar May 12 '24 20:05 AlexChalk