How to start a Clojure REPL since the Specs Alpha change
With the recent change in Clojure to use dedicated artifacts for Spec in an
alpha
sub-namespace, it is no longer easy to start a simple REPL just with
the regular jar
(e.g. java -jar $CLOJURE_JAR clojure.main
). So how to start
it now?
As of before you are better off to do a lein new
somewhere, change the
org.clojure/clojure
dependency to the version you like and do a lein deps
:tree
to fetch all that is needed and display what things org.clojure/core
now depends on. E.g.
[org.clojure/clojure "1.9.0-alpha17"] [org.clojure/core.specs.alpha "0.1.10" :exclusions [[org.clojure/clojure] [org.clojure/spec.alpha]]] [org.clojure/spec.alpha "0.1.123" :exclusions [[org.clojure/clojure]]]
All your artifacts end up in ~/.m2/repository
. So next you have to build up
your classpath to call the REPL. You can either run a lein with-profile uberjar cp
in that
dummy project to get the class path Leiningen is using (which often can be
quite long depending on all the plugins you run. Or you can guess the
locations from the versions above to build up the params for -cp
for
yourself.
M2="$HOME/.m2/repository" java -cp $M2/org/clojure/clojure/1.9.0-alpha17/clojure-1.9.0-alpha17.jar:$M2/org/clojure/spec.alpha/0.1.123/spec.alpha-0.1.123.jar:$M2/org/clojure/core.specs.alpha/0.1.10/core.specs.alpha-0.1.10.jar:. clojure.main
This is a very basic setup to get a basic REPL going, but paired with rlwrap
this is a few times faster to fire up than a lein repl
, which makes it
perfect to quickly fool around with some ideas.
On the horizon to streamline this, there is https://github.com/clojure/tools.deps.alpha.