Tuesday, September 20, 2011

Installing Clojure 1.2 on Ubuntu

If you're looking to install the latest stable version of Clojure on Ubuntu or a derivative, below are a few options. Currently, I'm running Ubuntu 10.10, whose package list contains Clojure 1.1.0. We can install this version using apt-get:

  $ sudo apt-get install clojure
$ clojure
Clojure 1.1.0
user=> (System/exit 0)

The most recent stable release is 1.2.1 (see Clojure Releases). It looks like while there was a request to have the available package updated to 1.2 (Ubuntu Bug #731979), but it looks like it won't be included by default until the 11.10 release of Ubuntu.

If we want to use the most recent stable release, the bug report has a link to the package set to be included in 11.10, clojure1.2, which we can install with dpkg:

  $ sudo dpkg -i clojure1.2_1.2.1+dfsg-3_all.deb

This links the clojure.jar as:

  $ ls -l /usr/share/java/clojure.jar
lrwxrwxrwx 1 root root 29 2011-09-20 10:39 /usr/share/java/clojure.jar -> /etc/alternatives/clojure.jar

Alternatively, we can download the source from the releases page and build it with ant ourselves: Clojure 1.2.1 Source.

  $ unzip clojure-1.2.1.zip
$ cd clojure-1.2.1
$ ant
Total time: 1 minute 57 seconds

If the build succeeds, we can just copy the built jar to the install location:

  $ sudo cp clojure.jar /usr/share/java/clojure.jar
$ clojure
Clojure 1.2.1
user=> (System/exit 0)

This approach should also work if we want to run the most recent development versions as well.

No comments:

Post a Comment