Any way to add dependency to lein project without REPL restart?

LoveProgramming picture LoveProgramming · May 7, 2013 · Viewed 10k times · Source

What I do now is open project.clj, add dependency there, run lein deps restart repl, then use, require and so on.

The thing is that I don't really like to restart repl because the startup time is slow and I have to reload my files again.

So is there a better way to add dependency to lein project? without restarting the repl?

Answer

i-blis picture i-blis · May 7, 2013

You can use Alembic, a dynamic classpath loader and dependencies resolver. The good thing is that it doesn't load all pomegranate dependencies.

Add the following to your .lein/profiles.clj:

{:user
  {:dependencies [[alembic "0.3.2"]]}}

Then in your Repl just load the classpaths you need, they will be pulled from the repositories by leinif need:

(require 'alembic.still)
(alembic.still/distill '[enlive "1.1.5"])

(require 'net.cgrand.enlive-html) should now work.