Refactor nrepl makes it possible to hotload a dependency into lein without rebooting the repl. This is awesome but it's not super well documented.
First, make sure you have the plugin installed by adding it to the :plugins
key of your
lein profile. This can be done per project in project.clj
, but is probably best to include in your
~/.lein/profiles.clj
Here's an example:
{:user {:plugins [[refactor-nrepl "1.1.0"]
:dependencies [[alembic "0.3.2"]
[org.clojure/tools.namespace "0.2.11"]
[org.clojure/tools.nrepl "0.2.7"]]
}
}
Now, from a REPL session you can hotload like this:
(refactor-nrepl.artifacts/hotload-dependency {:coordinates "[pandect \"0.5.4\"]"})
Notice that the argument is a map with a key of :coordinates
and a value which is an
EDN string of the lein dependency vector representing the library you want to load.
Not sure why this can't be passed is a quoted form, but the refactor-nrepl library
reads it using edn/read-string
, so you need to use the string format.
Wanted to try this but got thrown an exception and only then I realized this gist is from 7 years ago 🤷♂️