How to install the clojure development environment

Share

In this article, we will see how to rapidly install the clojure tools in a debian-like distribution (ubuntu 11.10 for example).

Pre-requisites

Installation

clojure

install

sudo aptitude install clojure

Note apt-get if you do not have aptitude installed.

check

Type clojure in a shell

clojure
user=>

You will have a repl in which you could ask some functions to eval.

user=> (+ 1 1)
2

leiningen 1

install

  • The easy way
    sudo aptitude install leiningen
    

    If you do not have leiningen in the packages, then you must pass by the not so hard way.

  • The not so hard way
    • Download the script
      wget https://raw.github.com/technomancy/leiningen/stable/bin/lein
      
    • Place it on your $PATH
      I also like to use ~/bin.
      export PATH=~/bin/:$PATH
      

      I usually add this in the ~/.bashrc file.

    • Make it executable
      chmod 755 ~/bin/lein
      
    • Ask the version
      This will download all it needs.
      lein version
      

      and finally gives you an output similar to this:

      tony@dagobah(0.11,) 09:56:26 ~/org (master) $ lein version
      Leiningen 1.7.1 on Java 1.6.0_26 Java HotSpot(TM) Client VM
      

check

tony@dagobah(0.16,) 13:00:07 ~ $ lein repl
REPL started; server listening on localhost port 14778
user=>

For example:

user=> (+ 1 1)
2

lein-midje

install

This is a leiningen plugin to launch unit tests for the unit test framework midje.

lein plugin install lein-midje 1.0.9

Note The version [lein-midje “2.0.0-SNAPSHOT”] is leiningen 2 compatible so do not use this one.

check

tony@dagobah(0.09,) 13:05:45 ~ $ lein midje --version
Couldn't find project.clj, which is needed for midje

OK

jdk installed (either sun or openjdk)

install

check

tony@dagobah(0.32,) 13:04:16 ~ $ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

git (optional)

install

sudo aptitude install git

check

tony@dagobah(0.10,) 13:05:41 (129) ~ $ git version
git version 1.7.5.4

Conclusion

We have focused on the needed steps to install the clojure environment. You now have all the tools to develop with clojure.

In a near future, i intend to make some other blog posts to focus on:

  • how to bootstrap a new clojure project using leiningen
  • how to solve a simple problem in clojure and show how these tools work together
  • continued integration with travis-ci
  • heroku for the deploying part
  • marginalia for the documentation generation and the github integration