clojure.main sets the thread context classloader to be a DynamicClassLoader, providing an environment to tap into the Clojure classloader environment. prepl should do the same. This would support things like add-lib when using prepl (for tools like REBL that use prepl).
Repro with rebl and add-lib...
Same problem also exists with clojure.core.server/repl, provided for use in a socket server.
Approach: Create a macro `with-dynamic-loader` that ensures (and doesn't replace if it exists) the thread context classloader, evaluates the binding, then reverts the loader. This macro is generic and could potentially be moved elsewhere.
Currently clojure.main/repl bakes in the creation of a DynamicClassLoader. The patch starts to stretch towards a reusable piece of functionality (with-dynamic-loader) and adds that into prepl and socket server.
Stu's comments from looking at this is that instead of baking this into repls we should really be pulling these things apart more. So in clojure.main/repl, maybe that should not be creating a DCL, but the caller of repl should be creating a DCL when needed. Needs some more thought on composition.