Install Clojure

Here's a quick, straightforward way to install Clojure on Linux or MacOS.

Install Java

First, you need the JDK. You can get that in a lot of ways. It's nice to have a utility to help you manager versions of the Java JDK. asdf is such a version manager -- and currently, the best.

Now with asdf, you can install the JDK. List what's available with:

asdf list all java

Then choose one to install, such as:

asdf install java openjdk-17.0.2

Now mark your project to use it:

asdf local java openjdk-17.0.2

Install Clojure on Linux

The linux install requires downloading the installer script. This differs by version. Go to the official install instructions for the latest url. As of this writing, it's:

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

Install Clojure on MacOS

If you're on Mac, you probably have brew installed. If not, get that. Then use brew to install Clojure:

brew install clojure/tools/clojure

Try it out

Now you should be able to start up a Clojure REPL with:

$ clojure

Clojure 1.11.1
user=> (+ 1 1)
2

Installed. Now go and wrap your life in parens.

Bonus: clj command

If you try to run the clj command (instead of clojure), you might get this error:

Please install rlwrap for command editing or use "clojure" instead.

To install rlwrap, run:

sudo apt install rlwrap