Search This Blog

Wednesday, November 18, 2009

Installing Clojure on Ubuntu 9.10 (Karmic Koala)


I have a nice fresh Ubuntu installation, on which I want to install Clojure, Emacs, and Slime. And I thought I'd document how it went:

There are packages for some things, but for this stuff I'd rather install bleeding edge versions by hand.

Instructions are here
http://riddell.us/tutorial/slime_swank/slime_swank.html





First install clojure and clojure-contrib
http://riddell.us/tutorial/clojure/clojure.html

That all goes swimmingly.

Now we need emacs
http://riddell.us/tutorial/emacs/emacs.html

Again, all is well, except that it's easier to use emacs to modify the .emacs file,
and his default font is the same as the usual one, only far too small on my machine, so I don't bother with that.

Now we have working up-to-date emacs and clojure.

On to the tricky bit, slime.

The instructions for installing swank and slime are here:

http://riddell.us/tutorial/slime_swank/slime_swank.html

Everything worked ok down to the "Test Configuration" section, where you use C-c C-k to compile the demo program ants.clj.

Nothing happens, and it rapidly becomes obvious that something is wrong.

It turns out that a recent change to slime broke clojure support.


To revert slime to the version just before the breaking change, use

cd ~/opt/slime
git checkout -b prebroken 33708dbf01adec2a91d198a798afed5032cdceca

Which creates a new branch, prebroken, at the last working version and changes the files in ~/opt/slime to be those that were then extant.

Thanks to Lauri below. I assume that's Lauri Pesonen?



Right, having reverted to the old version of slime, it all works.

As you evaluate each line in the ants file, a new thing happens in the window!





Description of the bug caused by latest changes to slime:

If I start a new emacs, then M-x starts  slime and seems to connect to a REPL.

But at this REPL, 

user> "hello"
"hello" 
    

That's ok!
                                                            
user> hello
; Evaluation aborted.


Even better. I'm looking at a clojure stack trace. q gets out, like it should.

user> '5
5

That's fine
                                                                          
user> ''5
(quote 5) 

So is that
                                                                 
user> (list 2 3 4)


Now everything seizes up.

This turns out to be related to a new feature of slime allowing it to highlight keyword arguments, or something.


The clojure version of swank can't deal with this new change and responds by hanging.


Presumable some wise persons will fix this eventually. For the moment just use a slightly out of date slime.




2 comments:

  1. The CVS HEAD of slime is broken when used with Clojure. This happened quite recently apparently. There's a thread about it on the clojure google group.

    The workaround is to get an older version of slime from CVS. I don't know if there's a clojure-specific fork of slime somewhere.

    Alternatively you can try using clojure-mode to install clojure, slime, and swank-clojure. I haven't done it myself, but I think the procedure is something like: install emacs, install clojure-mode, run M-x install-clojure. It should download everything you need and I'm assuming it will download known good versions of slime etc.

    -- Lauri

    ReplyDelete
  2. Lauri you're a genius. The breaking change was just after 33708dbf01adec2a91d198a798afed5032cdceca and that version works fine.

    So the command to fix it is:

    cd ~/opt/slime
    git checkout -b prebroken 33708dbf01adec2a91d198a798afed5032cdceca

    ReplyDelete

Followers