Installing Clojure With Leningen on Ubuntu 14.04 (October 2014)

This post is as much reference for myself as for anybody else. Installing Clojure and Leningen has a tiny bit of subtlety to it, so I am documenting the process here.

First, download leningen, copy it to /bin/, and make it executable:

1
2
3
$ wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
$ sudo cp lein /bin/lein
$ sudo chmod a+x /bin/lein

You don’t actually have to install to /bin/lein, but /bin/ is pretty much guaranteed to be on your PATH.

Now, the Leningen website says to “Run it (lein) and it will download the self-install package”. When I ran lein, I saw a list of available tasks, and there was no indication that anything had been downloaded. I think this instruction might be slightly out of date.

Instead, just go ahead and open a REPL; Leningen will download a clojure package at that time:

1
2
$ lein repl
Downloading: org/clojure/clojure/1.3.0/....

This worked great.

If you want to create an actual project, just run lein new project_name; lein won’t install anything when the project is created, but will download the needed dependencies if and when you run lein install.

You’ll still need to add code to your project before you can run anything useful with lein run and add some tests before you can test with lein test, but you’ll then be good to go!

Happy Coding!