Skip to content

Install Clojure CLIλ︎

Clojure CLI Logo

Install the Clojure CLI which provides the essential tools for Clojure development.

The Clojure CLI automatically downloads all library dependencies, including the Clojure Standard library. As Clojure itself is packages as a library (.jar Java ARchive), any version of Clojure can be used with a project.

Practicalli Clojure CLI Config extends the Clojure CLI with a range of development tools as well as configuration for Clojure LSP and cljstyle code format tool.

Practically recommends setting XDG_CONFIG_HOME to the .config directory, to avoid creating another dot directory in the root of the user account. Add the following to ~/.bashrc for the bash shell or ~/.zshenv for Zsh.

export XDG_CONFIG_HOME="$HOME/.config"

Use the Linux script installer from Clojure.org - Getting Started to install the latest stale release

curl -O https://download.clojure.org/install/linux-install.sh && \
chmod +x linux-install.sh && \
sudo ./linux-install.sh

The installation creates /usr/local/bin/clojure, /usr/local/bin/clj wrapper and /usr/local/lib/clojure directory.

Include version number for specific release

Clojure CLI linux install scripts include a number in their name to signify the version of Clojure and the version of Clojure CLI.

Include the version in the script name for repeatable environments, e.g. in Dockerfile configuration and Continuous Integraion workflows.

Clojure CLI install specific version
curl -O https://download.clojure.org/install/linux-install-1.11.1.1252.sh
chmod +x linux-install-1.11.1.1252.sh
sudo ./linux-install-1.11.1.1252.sh

Practically recommends setting XDG_CONFIG_HOME to the .config directory, to avoid creating another dot directory in the root of the user account. Add the following to ~/.bashrc for the bash shell or ~/.zshenv for Zsh.

export XDG_CONFIG_HOME="$HOME/.config"

Use the Homebrew command with the clojure/tools tap, as defined in the Clojure.org Getting started guide

brew install clojure/tools/clojure

Use Homebrew to update an install of Clojure CLI to the latest release

brew upgrade clojure/tools/clojure

Homebrew on Linux or Windows with WSL

For Windows 10 use Windows Subsystem for Linux and Windows Terminal are recommended if you have administrative privileges and are comfortable using a Unix system on the command line.

Alternatively install scoop.sh, a command line installer for windows. Powershell 5 or greater is required. Follow the scoop-clojure getting started guide, summarized here:

Open "Windows PowerShell" and enter the following commands to configure the shell:

iwr -useb get.scoop.sh | iex
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Then in the same PowerShell window, install the Clojure related tools using the following commands:

scoop bucket add extras
scoop bucket add java
scoop bucket add scoop-clojure https://github.com/littleli/scoop-clojure
scoop install git 7zip pshazz temurin-lts-jdk clj-deps leiningen clj-kondo vscode coreutils windows-terminal

Reference: Clojure CLI Install - Clojure.org Getting Started - official guide

Practicalli Clojure CLI Configλ︎

Add a wide range of community tools to extend the capabilities of Clojure CLI via the aliases contained within Practicalli Clojure CLI configuration.

Fork or clone Practicalli Clojure CLI Config GitHub repository, first removing the $XDG_CONFIG_HOME/clojure or $HOME/.clojure directory if they exist.

Check Clojure CLI configuration location

Check the location of your Clojure configuration directory by running clojure -Sdescribe and checking the :user-config value.

If XDG_CONFIG_HOME environment variable is set, clone the repository to $XDG_CONFIG_HOME/clojure

Via SSH

git clone git@github.com:practicalli/clojure-deps-edn.git $XDG_CONFIG_HOME/clojure

Via HTTPS:

git clone https://github.com/practicalli/clojure-deps-edn.git $XDG_CONFIG_HOME/clojure

Clojure CLI will look for its configuration in $HOME/.clojure directory if $XDG_CONFIG_HOME and CLJ_CONFIG environment variables not set. Via SSH ```shell git clone git@github.com:practicalli/clojure-deps-edn.git $HOME/.clojure

```

Via HTTPS
```shell
git clone https://github.com/practicalli/clojure-deps-edn.git $HOME/.clojure
```

Check Configurationλ︎

clojure -Sdescribe shows the version of Clojure CLI installed and configuration locations used.

clojure -Sdescribe

The output of the command includes the version of Clojure CLI in the :version key

{:version "1.11.1.1208"
 :config-files ["/usr/local/lib/clojure/deps.edn" "/home/practicalli/.config/clojure/deps.edn" ]
 :config-user "/home/practicalli/.config/clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/usr/local/lib/clojure"
 :config-dir "/home/practicalli/.config/clojure"
 :cache-dir "/home/practicalli/.cache/clojure"
 :force false
 :repro false
 :main-aliases ""
 :repl-aliases ""}

clojure -Sversion will shows the version of Clojure CLI being when the clojure command is used to run a REPL or other Clojure command.

Optional rlwrap readlineλ︎

The rlwrap binary is a basic readline tool that provides a history of commands entered into a terminal UI when running a Clojure REPL with the clj wrapper script.

Pressing the Up and Down keys will scroll through the code previously entered in the REPL.

rlwrap is available with most Linux systems. Look for install instructions by searching for rlwrap in a web browser or build from source from the rlwrap GitHub repository.

Use Rebel Readline for a rich terminal UI experience

rebel readline provides a auto-completion, documentation, signature help and multi-line editing all within a terminal UI, providing a much richer experience than the clj wrapper and rlwrap.

Rebel Readline is part of the Practicalli Clojure CLI config.


Last update: April 25, 2023