6.3 Installing Drake

Drake has quite a few dependencies, which makes its installation process rather involved. For the following instructions we assume that you are on Ubuntu.

If you’re using the Data Science Toolbox, then you already have Drake installed, and you may safely skip this section.

Drake is written in the programming language Clojure which means that it runs on the Java Virtual Machine (JVM). There are pre-built jars available but because Drake is in active development, we will build it from source. For this, you will need to install Leiningen.

  1. $ sudo apt-get install openjdk-6-jdk
  2. $ sudo apt-get install leiningen

Then, clone the Drake repository from Factual:

  1. $ git clone https://github.com/Factual/drake.git

And build the uberjar using Leiningen:

  1. $ cd drake
  2. $ lein uberjar

This creates drake.jar. Copy this file to a directory which is on your $PATH, for example, ~/.bin:

  1. $ mv drake.jar ~/bin/

At this point you should already be able to run Drake:

  1. $ cd ~/bin/
  2. $ java -jar drake.jar

This is not really convenient for two reasons: (1) the Java Virtual Machine (JVM) takes a long time to start and (2) you can only run it from that directory. We advise you to install Drip, which is a launcher for the JVM that provides much faster startup times than the java command. First, clone the Drip repository from Flatland:

  1. $ git clone https://github.com/flatland/drip.git
  2. $ cd drip
  3. $ make prefix=~/bin install

Then, create a Bash script that allows you to run Drake from everywhere:

  1. $ cd ~/bin
  2. $ cat << 'EOF' > drake
  3. > #!/bin/bash
  4. > drip -cp $(dirname $0)/drake.jar drake.core "$@"
  5. > EOF
  6. $ chmod +x drake

To verify that you have correctly installed both Drake and Drip, you can run the following command, preferably from a different directory:

  1. $ drake --version
  2. Drake Version 0.1.6

Drip speeds up Java because it reserves an instance of the JVM, after it has been run once. Because of this, you will only notice the speed up from the second time onwards.