Search code examples
emacsclojure

How do I update Clojure dependencies when working with nrepl.el?


As I understand it, when I do nrepl-jack-in a REPL is loaded along with all the dependencies defined in project.clj. If I then update project.clj to add a new dependency, do I need to kill the server and re-run nrepl-jack-in or is there way to update the dependencies in the current REPL?


Solution

  • Update: Maybe there is some hope, See https://github.com/cemerick/pomegranate

    Previously:

    The short answer is yes - you do have to restart the JVM process.

    I am aware of no good way to update dependencies in a live repl. Leiningen (called by nrepl-jack-in) will manage dependencies and set up the classpath only upon restarting. Trying to do something dynamic and clever is horribly fragile.

    The struck out text below is factually true but upon a moment's reflection seemed such bad advice I have marked it up as such...

    If you have a local dependency (e.g. jar file) you might use the long-time deprecated function add-classpath at the repl. But you will be entering the dragon infested swamp of java classloaders.