Clojure

Install Clojure

Intro

Clojure (the language) is provided as a Java ARchive (JAR) file, available in the Maven Central Repository, a public repository for JVM-based artifacts. If needed, you can find more detailed version information on the Releases page.

This page concerns the command-line tool (the Clojure CLI). This tool (used by the commands clojure and clj) can download Clojure itself and other Clojure or JVM-based libraries. Any version of the Clojure CLI can download or use any version of the Clojure language itself (they are independent).

The version numbers of the language and the CLI are separate but related. The Clojure language has a 3 part-version (like 1.11.3) and the Clojure CLI has a 4-part version (like 1.11.3.1456). The leading 3 parts of the CLI version indicate which version of the Clojure language will be used by default in a REPL, unless you specify otherwise in the deps.edn configuration file.

Mac OS instructions

Prerequisites: Java, brew

This adds the commands clojure and clj to your system from the clojure/tools tap:

brew install clojure/tools/clojure

If you already have the CLI installed, you can use this command to upgrade to the latest version:

brew upgrade clojure/tools/clojure

Linux instructions

Prerequisites: Java, bash, curl, rlwrap

To install with Linuxbrew (requires brew):

brew install clojure/tools/clojure

To install with the Linux script installer:

  1. Ensure that the following dependencies are installed: bash, curl, rlwrap, and Java.

  2. Use the linux-install script to download and run the install, which will create the executables /usr/local/bin/clj, /usr/local/bin/clojure, and the directory /usr/local/lib/clojure:

curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh
chmod +x linux-install.sh
sudo ./linux-install.sh

To install to a custom location (like /opt/infrastructure/clojure), use the option --prefix:

sudo ./linux-install.sh --prefix /opt/infrastructure/clojure

You may also want to extend the MANPATH in /etc/man_db.conf to include the manual pages:

MANPATH_MAP /opt/infrastructure/clojure/bin /opt/infrastructure/clojure/man

The linux-install script can be removed after installation.

Posix instructions

A POSIX version of the linux installer is now available as well. This installer should work on Linux, BSD, and even Mac (but will conflict with brew!)

To install with the POSIX script installer:

  1. Ensure that the following dependencies are installed: bash, curl, rlwrap, and Java.

  2. Use the posix-install script to download and run the install, which will create the executables /usr/local/bin/clj, /usr/local/bin/clojure, and the directory /usr/local/lib/clojure:

curl -L -O https://github.com/clojure/brew-install/releases/latest/download/posix-install.sh
chmod +x posix-install.sh
sudo ./posix-install.sh

To install to a custom location (like /opt/infrastructure/clojure), use the option --prefix:

sudo ./posix-install.sh --prefix /opt/infrastructure/clojure

You may also want to extend the MANPATH in /etc/man_db.conf to include the manual pages:

MANPATH_MAP /opt/infrastructure/clojure/bin /opt/infrastructure/clojure/man

The posix-install script can be removed after installation.

Windows instructions

Prerequisites: Java

An early release version of clj on Windows is available at clj on Windows. Please provide feedback on Ask Clojure or Clojurians slack in #clj-on-windows.

Prerequisite installation details

brew (Mac or Linux)

brew is a package manager for Mac OS X or Linux. To install brew:

Java

Clojure requires Java. Clojure officially supports Java LTS releases (currently Java 8, 11, 17 and 21), but also tries to ensure interim versions work as well. You can use any Java distribution, whether it’s a commercial release from Oracle or an open source version based on OpenJDK (like Temurin). The Clojure tools require only that the java command is on the PATH or that the JAVA_HOME environment variable is set.

If you don’t already hava Java installed, we recommend installing Adoptium Temurin 21.

To use the Adoptium Temurin installers:

  • Go to https://adoptium.net/

  • Download and run the installer appropriate to your platform

  • Ensure java is on the system PATH

On Mac, you can also install Temurin using brew:

  • brew tap homebrew/cask-versions - add the cask-versions tap to Homebrew

  • brew install --cask temurin21 - install Temurin 21 (formerly AdoptOpenJDK)

Check your Java version by running java --version. If that’s not Temurin 21, then you may then need to add java to your PATH:

echo 'export PATH="/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home/bin:$PATH"' >> ~/.zshrc

Installing archive or prerelease versions of the CLI

For other versions of the Clojure CLI, see the changelog for version history and the Clojure tap for info on installing older versions or newer prereleases instead.

Original author: Alex Miller