Clojure provides the clojure
command line tool for:
- Running an interactive REPL (Read-Eval-Print Loop)
- Running Clojure programs
- Evaluating Clojure expressions
The clojure
tool is written in bash. This is a port of that tool written in
Clojure itself.
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 succesfully 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 withcmd.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
orplanck
. -
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.
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.exe
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 non-standard options:
-Sdeps-file Use this file instead of deps.edn
-Scommand A custom command that will be invoked. Substitutions: {{classpath}}, {{main-opts}}.
Given this script-deps.edn
file:
{:paths ["scripts"]
:aliases
{:main
{:main-opts ["-m" "scripts.main"]}}}
and scripts/main.cljc
:
(ns scripts.main)
(defn -main [& _args]
(println "Hello from script!"))
you can invoke deps.clj
as follows to invoke
babashka:
$ deps.clj -Sdeps-file script-deps.edn -A:main -Scommand "bb -cp {{classpath}} {{main-opts}}"
Hello from script!
This can also be used with planck:
$ deps.clj -Sdeps-file script-deps.edn -A:main -Scommand "planck --classpath {{classpath}} {{main-opts}}"
Hello from script!
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.