Installing Clojure on Nitrous.IO platform


I’ve evaluated Nitrous.IO service for a few weeks now. In a nutshell it allows you to create virtual, development, environment, to which you can connect remotely (using the terminal, but also the web page, chrome app or even Mac app). By default Nitrous.IO comes with preconfigured boxes with Ruby/Rails, Node.js, Python/Django and Go.

I’ve started using Nitrous, because I wanted to have an easy and fast access to programming languages without installing them on my Windows machine.

Lately I try to get my head around Clojure language (I’ve learned functional programming during my studies, but it was a long time ago, so I have to discover it again). Because of that I wanted to install Clojure on the Nitrous.IO platform. It isn’t hard, but requires few steps to do. Below I will show you, how you can do it (this tutorial is inspired by ‘Installing Erlang’ guide).

Let’s start:

  • Create a new development box (I’ve used the one with the Go language, but it doesn’t matter) or use the existing one.

  • Connect to the box - you can even use the web page - start terminal then.

  • The easiest way to install Clojure on any system is to use Leiningen tool. First lets make a folder where we will store installation script:

mkdir ~/.tools

then we should get the script:

cd .tools
wget https://raw.github.com/technomancy/leiningen/stable/bin/lein
  • Once the script is downloaded, we need to modify ~/.bashrc file to add the .tools directory to our $PATH - we can do it with the vim:
vim ~/.bashrc

add this line to the end of the file:

PATH=$PATH:$HOME/.tools/

save and exit.

  • Reload the ~/.bashrc file:
source ~/.bashrc

and check if the $PATH contains .tool directory

echo $PATH

the output should be similar to this one:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/action/.gem/ruby/1.9.1/bin:/home/action/.go/bin:/home/action/workspace/bin:/home/action/.google_appengin

e:/home/action/.go/bin:/home/action/workspace/bin:/home/action/.google_appengine:/home/action/.tools/
  • Now we need to set Leiningen script to be executable
chmod a+x ~/.tools/lein

and we are ready to go.

  • To start using Clojure REPL (read-eval-print loop) type:
lein repl

For the first time Leiningen will download and install Clojure, after it finishes you can start playing with the new language.

If you need more information about Leiningen, you can read the documentation.

A small tip if you work in the web page terminal, you can copy or past using those shortcuts:

Windows Users:
Copy: Shift + Ctrl + c
Paste: Shift + Ctrl + v

Mac Users:
Copy: Command + c
Paste: Command + v


You may also like

Lesser known Clojure: variants of threading macro

ClojureScript: JavaScript Interop

Template method pattern