Installation
Prerequsites
CIDER 0.14.0 (the version current at the writing of this presentation) has the following prerequisites:
- Emacs 24.4 or later
- Java: Oracle Java or Open JDK 1.7 or later
- Clojure/ClojureScript 1.7 or later
- Clojure Project Build Tool: Leiningen, Boot or Gradle. This presentation will use Leiningen- the defacto Clojure project build tool.
Emacs
As noted in the Introduction, this presentation assumes the reader is an active Emacs user and therefore has Emacs installed. If the reader is not an active (or experienced) Emacs user, the tutorial How to Use Emacs, an Excellent Clojure Editor on the Brave Clojure site is recommended.
Java
Clojure is a JVM-based language and therefore requires an installation of Java.
If you do not have Java 1.7 or later installed, install the version of Java appropriate for your OS:
OS X (Oracle Java): Instructions | Downloads
Windows (Oracle Java): Instructions | Downloads
Linux:
Users of the popular Linux distributions and their derivatives have the choice of either OpenJDK or Oracle Java. In terms of the licensing model and ease of installation (installation via your Linux package manager), OpenJDK is recommended. In terms of support and stability, Oracle Java is recommended.
- OpenJDK: Instructions
- Oracle Java:
- Linux (Generic):
- Debian 8: Instructions
- Unbuntu 16.04: Instructions
- RHEL/CentOS/Fedora: Instructions
After you have installed Java, ensure that:
- JAVA_HOME points to the root of the Java install directory.
- The Java 'bin' directory is on your PATH.
- The command
java -version
returns version 1.7 or higher.
Leiningen
Leiningen is the de facto standard project build/automation tool for Clojure. Leiningen serves the same purpose as make, Maven, Gradle, and Rake do for their respective languages.
For Leiningen-based Clojure projects, CIDER uses Leiningen to launch a Clojure REPL from Emacs.
CIDER also supports Clojure projects that use Boot and Gradle but this tutorial will cover Leiningen.
The standard installation method for Leiningen varies depending on the OS:
Linux and Mac OS X (this is the preferred installation method):
- Download the lein script
curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
- Make the script executable:
chmod a+x lein
- Ensure that the directory containing the
lein
script is on your PATH
- Download the lein script
Windows:
Download the lein.bat script
Ensure that the directory containing the
lein.bat
script is on your PATH
Alternative installation methods:
- Mac OS X:
- Homebrew:
brew install leiningen
- SDKMAN:
sdk install leiningen
- Homebrew:
- Windows:
- Windows Installer
- Chocolatey:
choco install lein
- Linux:
- SDKMAN:
sdk install leiningen
- SDKMAN:
- Other OS's - https://github.com/technomancy/leiningen/wiki/Packaging
Finally, validate your Leiningen install:
- Run
lein version
to display the Leiningen version. - Run
lein repl
to launch a Clojure REPL. Type(exit)
to exit the REPL.
CIDER
CIDER is installed via Emacs' built-in package management facility, package.el (also known as ELPA- Emacs Lisp Package Archive). CIDER is available in the MELPA package repository.
Ensure that you have the following in your Emacs init file (.emacs/.emacs.el/init.el):
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
(package-initialize)
Now install the CIDER package and it's dependencies:
M-x package-install [RET] cider [RET]
Verify CIDER is installed by executing the following:
M-x cider-version [RET]