Search code examples
clojurelibrariesread-eval-print-loop

Using Medley.core lib in clojure repl


Is there a way to use the medley library directly in clojure's repl without adding it to the :dependencies in the project.clj file? Something like (use 'medley.core)?


Solution

  • You could add pomegranate to your $HOME/.lein/profiles.clj file

    {:user {
        :dependencies [[com.cemerick/pomegranate "0.3.0"]]
     }}
    

    Then, from the repl, you can require pomegranate functions with:

     (use '[cemerick.pomegranate :only (add-dependencies)])
    

    Then add your dependency like this:

      (add-dependencies
         :coordinates '[[incanter "1.2.3"]]
         :repositories {"clojars" "http://clojars.org/repo"}))
    

    Most of the time, Clojure libraries do use a maven compatible repository named clojars, hence the extra repository, but if the library is on the maven central, no need for the extra repository definition.

    For example, bootstrap-clj is on central, so in that case, the below is enough:

      (add-dependencies 
       :coordinates '[[com.github.sebhoss/bootstrap-clj "2.0.0"]])
    

    Voila.