Clojure provides the clojure
command line tool for:
The clojure
tool is written in bash. This is a port of that tool written in
Clojure itself. It comes in two flavors:
deps.clj
deps.exe
Linux and macOS:
$ bash <(curl -s https://raw.githubusercontent.com/borkdude/deps.clj/master/install)
$ deps.exe
Clojure 1.10.1
user=>
Windows:
C:\> PowerShell -Command "iwr -useb https://raw.githubusercontent.com/borkdude/deps.clj/master/install.ps1 | iex"
C:\> deps.exe
Clojure 1.10.1
user=>
Reasons why I made this:
The port was done as proof of concept for
babashka. The entire bash script was
ported to Clojure successfully and runs just as fast with bb
.
This offers an arguably easier way to get going with deps.edn
based projects
in CI. Just download an installer script, execute it with bash or Powershell and you're set. Installer scripts are provided for linux, macOS and Windows.
Windows users might find the deps.exe
executable of value if they have
trouble getting their system up and running. It works with cmd.exe
unlike the
current Powershell based approach.
This repo might be a place to experiment with features that are not available
in the original clojure
command. Most notably it offers an -Scommand
option
which allows other programs to be started than just the JVM version of Clojure,
e.g. babashka
or
planck
.
Arguably bash and Powershell are less attractive languages for Clojure
developers than Clojure itself. This repo provides the clojure
bash script as
a port in Clojure. It can be used as a binary, script (deps.clj
), uberjar
or library.
This repo can be seen as a proof of concept of what is possible with GraalVM and Clojure.
Experimental, but in a usable state. Breaking changes might happen to the non-standard functionality. Feedback and PRs are welcome.
There are three ways of running:
deps.exe
which is tailored to your OSdeps.clj
using bb
or clojure
The binary version of deps.clj, called deps.exe
, only requires a working
installation of java
.
Binaries for linux, macOS and Windows can be obtained on the Github releases page.
Install using the installation script on linux or macOS:
$ bash <(curl -s https://raw.githubusercontent.com/borkdude/deps.clj/master/install) /tmp
$ /tmp/deps.exe
Clojure 1.10.1
user=>
On Windows you might want to install deps.clj
using
scoop.
Alternatively you can install deps.exe
using by executing the following line:
C:\> PowerShell -Command "iwr -useb https://raw.githubusercontent.com/borkdude/deps.clj/master/install.ps1 | iex"
C:\> deps.exe
Clojure 1.10.1
user=>
It's automatically added to your path. In Powershell you can use it right away. In cmd.exe
you'll have to restart the session for it to become available on the path.
When you get a message about a missing MSVCR100.dll
, also install the
Microsoft Visual C++ 2010 Redistributable Package
(x64) which is
also available in the
extras
Scoop bucket.
The script, deps.clj
, requires a working installation of java
and
additionally bb
or clojure
.
It can simply be downloaded from this repo:
$ curl -sL https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj -o /tmp/deps.clj
$ chmod +x /tmp/deps.clj
$ bb /tmp/deps.clj
Clojure 1.10.1
user=>
This project will look in $HOME/.deps.clj/ClojureTools
for
clojure-tools.jar
. If it cannot it find it there, it will try to download it
from this
location. You can override the location of the jar with the CLOJURE_TOOLS_CP
environment variable.
The deps.clj
script adds the following features compared to the clojure
tool:
-Sdeps-file Use this file instead of deps.edn
-Scommand A custom command that will be invoked. Substitutions: {{classpath}}, {{main-opts}}.
It also is able to pick up proxy information from environment variables.
One of the use cases for deps.clj
is invoking a different command than java
.
Given this deps.edn
:
{:aliases
{:test
{:extra-paths ["test"]
:extra-deps {borkdude/spartan.test {:mvn/version "0.0.4"}}
:main-opts ["-m" "spartan.test" "-n" "borkdude.deps-test"]}}}
you can invoke bb
like this:
$ deps.clj -A:test -Scommand "bb -cp {{classpath}} {{main-opts}}"
Ran 3 tests containing 3 assertions.
0 failures, 0 errors.
If you use -Scommand
often, an alias can be helpful:
$ alias babashka='rlwrap deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
$ babashka -A:test
Ran 3 tests containing 3 assertions.
0 failures, 0 errors.
Additional args are passed along to the command:
$ babashka -e '(+ 1 2 3)'
6
Note that we included rlwrap
for a better REPL experience. Of course you can create another alias without rlwrap
for CI:
$ alias bbk='deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
This approach can also be used with planck or lumo:
$ alias lm='deps.clj -Scommand "lumo -c {{classpath}} {{main-opts}}"'
$ lm -Sdeps '{:deps {medley {:mvn/version "1.2.0"}}}' -K \
-e "(require '[medley.core :refer [index-by]]) (index-by :id [{:id 1} {:id 2}])"
{1 {:id 1}, 2 {:id 2}}
The -Sdeps-file
option may be used to load a different project file than deps.edn
.
TODO
Copyright © 2019 Michiel Borkent
Distributed under the EPL License. See LICENSE.
This project is based on code from clojure/brew-install which is licensed under the same EPL License.
Can you improve this documentation? These fine people already did:
Michiel Borkent & sundbpEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close