So I have this workflow problem:
I'm happily typing away on my clojure project repl and realise that i need another library that is not in my project.clj
, say in this case, i needed the tools.cli
library.
I open up project.clj
in my editor and add in an entry to the :dependencies
[org.clojure/tools.cli "0.2.1"]
Then, within the project directory, I type lein deps
in the shell to pull in the necessary libraries
After the project dependencies are pulled, technically all the class files are already there ready to be loaded, but if I go back to my repl and type:
> (use 'tools.cli)
I get this:
=>> FileNotFoundException Could not locate tools/cli__init.class
or tools/cli.clj on classpath: clojure.lang.RT.load (RT.java:432)
So I would have to restart my repl, wasting a whole heap of time reconfiguring the state of the repl to where I was before I needed the library.
Is there a way to just load in the library dynamically? eg, after I run lein deps
I just go back to the repl and type:
> (load-library "tools.cli")
> (use 'tools.cli)
Thanks in advance
A Clojure REPL (standing for Read-Eval-Print Loop) is a programming environment which enables the programmer to interact with a running Clojure program and modify it, by evaluating one code expression at a time.
Starting a REPL Session To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application. This will start a new REPL session in a separate window along with the console output.
Pomegranate is for you:
https://github.com/cemerick/pomegranate
It supports download and addition of new dependencies at runtime, e.g.:
(add-dependencies :coordinates '[[incanter "1.2.3"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
{"clojars" "http://clojars.org/repo"}))
Will something like this work for you?
https://groups.google.com/d/msg/clojure/AJXqbpGMQw4/0-7-3pXRwGkJ
There is also clojure.core/add-classpath, but it's deprecated.
http://clojuredocs.org/clojure_core/clojure.core/add-classpath
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With