Thursday, May 13, 2010

Installing Compojure from a clean Ubuntu

This is a rough draft of my steps for the all the frustrated people who tried to get Compojure to work. Disclaimer: This is the first time I've ever used any version of Linux and ever tried to do anything in Linux.
----

Got irritated while trying to configure Windows cause I wanted to use Compojure.. (Clojure's web development framework.)

Finally, I gave up and installed Ubuntu. (Bye Windows..)

1. Wubi - Start clean
I downloaded Wubi. Went through the default installation, and let the update manager update everything once.

2. EMACs - Text editor for Clojure, with the necessary modifications
Next, I followed the steps outlined (http://www.bestinclass.dk/index.php/2009/12/clojure-101-getting-clojure-slime-installed/)

EMACs
https://help.ubuntu.com/community/EmacsHowto
sudo apt-get install emacs-snapshot-gtk
Run EMACs by using Alt-F2, "emacs".

You have to configure emacs properly for Clojure.
In emacs, Type: M-x package-list-packages (You should have "EPLA").
Select the following options by clicking on them, typing "I" for each of the options, then type "x"

Installed in emacs
clojure-mode
clojure-testmode
slime-repl
paraedit
magit
swank-clojure

3. Git (for downloading code and libraries)
http://book.git-scm.com/2_installing_git.html
$sudo apt-get install git-core

4. Leiningen
http://alexott.net/en/clojure/ClojureLein.html
Follow the instructions to install Leiningen. (Thanks Alex Ott!))

(Some stuff that might be important for Terminal commands:
echo $PATH - find your path)

5. Your first "Hello World" Compojure project

http://kzar.co.uk/blog/view/installing-compojure
All the instructions on "http://weavejester.github.com/compojure/docs/getting-started.html" are essentially correct, except that you must add to the dependencies in project.clj the swank dependency

Open project.clj in emacs and add
:dev-dependencies [[leiningen/lein-swank "1.2.0-SNAPSHOT"]

Then in Terminal:
lein deps

Then run:
lein swank (to start a swank server)
You should see the swank server running.

Then switch to EMACs and type
M-x slime-connect
You should see emacs connecting.

Run: (run-jetty example {:port 8080})

6. Verification
Open up a browswer, and type http://localhost:8080. It should show "Hello World".

----
P.S.
Sorry for the awkward formatting, going off to bed first. Hopefully, this will help everyone trying to use Compojure. I included all the pages I used, and much thanks to everyone who wrote those articles as guides.

Ryan

2 comments: