Skip to content

Install Clojure CLIλ︎

Clojure CLI Logo

Clojure CLI is a command line tool for running a Clojure REPL, project or tool.

Clojure CLI automatically downloads required library dependencies, including the Clojure Standard library.

Clojure distributed as a library

Clojure is distributed as a library (.jar Java ARchive) via Maven Central.

A deps.edn file specifies the version of Clojure to be used with a project.

:deps {org.clojure/clojure {:mvn/version "1.12.0"}}

The Clojure CLI tool provides a default Clojure library version if not specified in the project or user deps.edn files.

Clojure releases

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.

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

curl -L -O https://github.com/clojure/brew-install/releases/latest/download/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.

Use alternative location - unattended install

--prefix option specifies an alternative lolcation for the Clojure CLI install.

When permissions are not available or for automating the install without password prompt, use a local user specific install, e.g.

curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh && \
chmod +x linux-install.sh && \
./linux-install.sh --prefix $HOME/.local/

Include version number for specific release

Each Clojure CLI version is a number that represents the version of Clojure used and the build version of the Clojure CLI tool, e.g. 1.11.1.1413.

Clojure CLI Releases page

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 -L -O https://github.com/clojure/brew-install/releases/1.11.1.1413/download/linux-install.sh && \
chmod +x linux-install-1.11.1.1413.sh
sudo ./linux-install-1.11.1.1413.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 and $HOME/.clojure directory if they exist.

Practicalli recommends using FreeDesktop XDG configuration locations

Practically recommends setting XDG_CONFIG_HOME to the .config directory, to avoid creating another dot directory in the root of the user account.

Configure ~/.bashrc for the bash shell

Bash .bashrc file
export XDG_CONFIG_HOME="$HOME/.config"

Configure ~/.zshenv for Zsh

# Set XDG_CONFIG_HOME for clean management of configuration files
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:=$HOME/.config}"
export XDG_DATA_HOME="${XDG_DATA_HOME:=$HOME/.local/share}"
export XDG_CACHE_HOME="${XDG_CACHE_HOME:=$HOME/.cache}"
export ZDOTDIR="${ZDOTDIR:=$XDG_CONFIG_HOME/zsh}"

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-cli-config.git $XDG_CONFIG_HOME/clojure

Via HTTPS:

git clone https://github.com/practicalli/clojure-cli-config.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-cli-config.git $HOME/.clojure

```

Via HTTPS
```shell
git clone https://github.com/practicalli/clojure-cli-config.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.1386"
 :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.