Until this week, I had been putting off setting up a CL/Emacs/SLIME environment from scratch ever since I had trouble getting ASDF to work with Lispbox. Every time I tried, I ran into some will-sapping problem like needing to find a good Windows program for .tar.gz files, or finding the command line flags to get CLISP to run right, or figuring out the best way to setup a folder structure that matches the Unix folders used by most Lispers. Every time I fixed one problem, I ran into another. For someone out there trying to do a setup like this, there are lots of good resources, but they are either incomplete or outdated.
For instance, the Common Lisp Cookbook has a very thorough page on Setting Up an IDE with Emacs on Windows or Max OSX, but as far as I can tell, it’s from 2004 or earlier because it doesn’t mention SBCL or SLIME, two of the most popular pieces of CL development software today. Or when you run into a specific problem, it’s usually not too hard to find an answer, but it might not match the setup you’re using. That’s why I had to quit using Lispbox, because no one had any clue how it was configured, especially not on Windows. n00bs didn’t know the answers and the wizards had a traditional setup.
Here are some of the variables that contribute to the combinatorial explosion of configuration, in order or pain caused:
- Operating system: Linux (many flavors), Mac, Windows, Cygwin
- CL implementation: most common are SBCL, CMUCL, Allegro, LispWorks, CLISP
- CL implementation version (I ran into a problem here)
- SLIME version (stable 2.0 release or CVS snapshot)
- Emacs version (I didn’t run across any problems with this)
- I almost forgot, now there’s Cusp/Eclipse if you don’t want to use Emacs/SLIME, but right now Cusp is only tested on SBCL.
Maybe someday someone will try out all of those combinations and report, but for today, I did exactly one: Windows XP, CLISP 2.44, SLIME CVS, and Emacs 22.2 Why CLISP? After reading lots of internet, I came to the conclusion that (aside from the commercial CLs), CLISP is the best implementation for Windows users. The knocks against it are that it’s slow because it’s byte-code compiled, it doesn’t have threads, and on some points, it’s ideologically different from CL and other implementations.
Well, the performance isn’t a big concern for me (plus as I went to press, 2.45 was released with experimental JIT compilation), the threads also aren’t a big deal right now, and I think the differences will help me be aware of the considerations for writing portable code. Also regarding the SBCL windows port, it’s still considered experimental (currently v1.013 for Windows) but people are saying it’s stable and everything works except the threads. There’s even an msi installer for the Windows version. One of my next projects will be to dive into the SBCL documentation and mailing lists to get a better feel for it.
As far as the philosophy behind this (and future) setup guides, I want them to be a) thorough and b) instructive. Instructive? If you just want to take my word for everything, that’s fine, but I want you to know where I got my info from, so I’ve tried to include links to references for each step. On to the setup guide!
0. Files to Download
If you want to get started on downloading the setup files, here are the links:
- 7-zip (download v4.57 – 840K) – for unpacking .tar and .tar.gz files commonly used in *nix.
- Emacs (download v22.2 – 37MB)
- CLISP (download v2.44 – 4MB)
- SLIME (download CVS snapshot – 700K) – CLISP recently removed a function used in the 2.0 version of SLIME, but the SLIME CVS snapshot has that fixed
1. Setup Directories
Windows XP loves extremely long pathnames like C:\Documents and Settings\Username\Application Data. This is okay if for GUI-driven apps, but in Emacs, you’re not clicking, you’re typing, and you want short path names. Also, much (most?) of the open source Common Lisp tools are developed on *nix, so there’s less impedance mismatch when using stuff off the net if you have a *nix-ish folder structure.
Start with a root folder. In the pathnames in the rest of this guide, I’ll refer to it as [HOME]. I used C:\home\ to match the *nix convention of having user files be in /home/username/. You also need a username directory – I called mine peter and I’ll refer to it as [USR]. So in my case, [HOME]/[USR] would be C:\home\peter\.
Emacs NOTE #1: One important point about filenames in Emacs is that they CAN be entered with ‘/’, but if you prefer to use ‘\’, you have to escape it with another back slash, so in Emacs buffers and files, you would enter “C:/home/” or “C:\\home\\” but never “C:\home\”. The trailing slash is also important because it indicates that it’s a directory. Now that you have chosen your [ROOT] and [USR] values, these are the folders you should setup:
- [HOME]\[USR]\
- [HOME]\[USR]\site\
- [HOME]\[USR]\docs\
- [HOME]\[USR]\lisp\
- [HOME]\[USR]\info\
- [HOME]\bin\
2. Setup Emacs
Emacs does not need to be “installed” like most Windows apps – it just runs from its directory. Extract it to [HOME]\bin\. I changed the folder name from emacs-22.2 to just emacs, so my path was c:\home\bin\emacs\. You run emacs by running the file [HOME]\bin\emacs\bin\runemacs.exe.
Emacs settings are stored in a configuration file called “.emacs”. On Windows, the default working folder and .emacs location is C:\Documents and Settings\Username\Application Data, but that’s too painful to type and it’s a hidden folder so it’s not even easy to get through with the GUI. To have Emacs work in a different folder, create a file called site-start.el in the emacs\site-lisp folder. In that folder, put the following line (but change the path to match yours):
(setenv "HOME" "[HOME]/[USR]/")
(Thanks Nathaniel! This was probably the biggest annoyance of mine that made me put off finishing setup for so long.)
Emacs NOTE #2: Emacs has lots (and lots and lots) of keyboard shortcuts, many more than there are letters in the alphabet. Many of them require multiple keys or a sequence of keys called a “chord”. The two modifier keys used are Control and Alt (also called Meta). The common way to write chords is to use C- and M- for Control and Meta, so to run the command to close Emacs, you hold down Control and X, then let go, then hold down Control and C. This is written as C-x C-c. Sometimes a chord is followed by another letter or the name of a command. For instance, to undo, you hold Control and x, then let go and hit u. This is written as C-x u. Dashes mean press at the same time, space means let go. Easy! I made a cheat sheet for common commands in Emacs and SLIME.
Now it’s time to create your .emacs file. Run emacs and hit C-x C-f. This is the find command, which is used to create or open a file. At the prompt “Find file: “, type “~/.emacs” (without quotes). Right now just put a ; (that’s the comment marker in Emacs Lisp files) and save it by hitting C-x C-s. There’s a world of stuff you can put in a .emacs file, but that’s too much to bite off now.
3. Install CLISP
This is easy if you download the install package (that’s the one I linked to). Run the installer and choose [HOME]\bin\clisp\ as the install directory. That’s it!
4. Setup SLIME
CLISP changed recently (around version 2.44 – not sure exactly) and broke compatibility with the SLIME 2.0 release. This was fixed in development and the CVS snapshot works. If you try to use the 2.0 release, you’ll get an error that looks like this:
INTERN(“FRAME-UP-1”): #<PACKAGE SYSTEM> is locked
So use the CVS snapshot (which I linked to) and you should be fine.
Extract the SLIME folder to [HOME]\bin\emacs\site-lisp. (Here’s a tip about putting emacs code in site-lisp).
Now in Emacs, open your .emacs file (C-x C-f, ~/.emacs) and enter the following (general SLIME instructions, CLISP specific parameters), changing your pathnames as usual:
(setq inferior-lisp-program “[HOME]/bin/clisp/full/lisp.exe
-B [HOME]/bin/clisp/full
-M [HOME]/bin/clisp/full/lispinit.mem
-ansi -q”)
(add-to-list ‘load-path “[HOME]/bin/emacs/site-lisp/slime/”)
(require ‘slime)
(slime-setup)
Save the .emacs file (C-x C-s), then run the eval-buffer command (M-x eval-buffer). This will run the code that you just entered and tell Emacs how to run SLIME.
Now, you start slime with M-x slime and you’re ready to go!
————————————–
I hope this works for you – I ran through it on another computer and it worked the first time, so if you use exactly these parts you should be OK. Please let me know if you run into problems so I can incorporate the fix into my doc. Many thanks to everyone who I linked to, since they did the coding, testing, and writeups that I used to get here. More resources to come – tell me what you’d like to see. If it’s something I was planning on doing anyway, I’ll move it up my queue.
The next guide will probably be setting up your built-in documentation (Hyperspec, etc).
corporate drone says
Excellent guide. Thanks! I believe that there are many who develop for Windows that would like to use Lisp for creating domain specific languages. If basic installation is too difficult people will just use an alternative that offers better platform support. There are now many functional alternatives to Lisp that fill the same space.
Peter says
Thanks, drone. While this isn’t an easy install by Windows standards, it is debugged and predictable. I tried to be thorough enough that anyone could get through in on the first try.
#6 says
Interesting article. Also, an astounding waste of time, like putting functioning arms and legs on a piece of dog feces. If you’re doing hardcore software development or computer science using CLISP, why would you ever do it on an XP machine? The mind boggles.
A quicker method.
Download and install VMware
Download and install some unix on the VMware installation
Install CLISP and SLIME and EMACS on the VMware unix. If you do this on Ubuntu, one command line will do this.
But windows isn’t for serious tasks.
Peter says
Thanks, troll. VMware is a good tip, one that I started to pursue but found to be a hassle. As much as you (and many of your species) dislike Windows, it has the big benefit that hundreds of millions of people know how to use it! Learning Lisp and Emacs is a challenge enough; having to learn *nix at the same time is too much to bother with.
I wrote this for Windows because that’s where the people are.
Зарт says
Patch:
2,3c2,3
< -B c:/[HOME]/bin/clisp/full
-B [HOME]/bin/clisp/full
> -M [HOME]/bin/clisp/full/lispinit.mem
5c5
(add-to-list ‘load-path “[HOME]/bin/emacs/site-lisp/slime/â€)
, where “[HOME]” could be “c:/home”.
w-g says
The 2.0 SLIME release is really ancient. Get the CVS version with the FAIRLY-STABLE tag:
export CVSROOT=:pserver:anonymous@common-lisp.net:/project/slime/cvsroot
cvs login
_(The password is `anonymous’)_
cvs checkout -rFAIRLY-STABLE slime
Зарт says
2,3c2,3
< -B c:/[HOME]/bin/clisp/full
< -M c:/[HOME]/bin/clisp/full/lispinit.mem
—
> -B [HOME]/bin/clisp/full
> -M [HOME]/bin/clisp/full/lispinit.mem
5c5
< (add-to-list ‘load-path “[HOME]/emacs/site-lisp/slime/â€)
—
> (add-to-list ‘load-path “[HOME]/bin/emacs/site-lisp/slime/â€)
jon says
Use clbuild
Dave says
Thanks for this – I had only just started to look for information on how to get SLIME working properly on Windows when I found your post right at the top of comp.lang.lisp – you have saved me much googling and frustration! Good lisp implementations on Windows are few and far between unless you’re prepared to pay through the nose for one of the commercial versions, so it’s great to have this information out there.
And #6 – excellent trolling. Suggesting the installation of a entire operating system just to get one application running made me smile.
Joe says
Thank you very much for your excellent guide! I’ve been trying to get Emacs, CLisp and Slime to work together under Windows (not using LispBox) for some time now — with mounting frustration. Your explanation was crystal clear, and most importantly, it worked the first time.
And like Dave, I too thought #6’s suggestion was entertaining. You are right: Windows is where the people are.
Alex says
Excellent! I’ve been stuck for ages by the incompatibility issue between CLISP 2.45 and Slime. Thanks!
fincomus says
Thanks a lot. Very helpfull.
waterbreath says
I searched my brains out for something like this about a year ago.
(BTW “will-sapping” is a great term for this kind of masochistic activity that I always seem to have to slog through when I deal with F/OSS software. I really wish this weren’t the case, but it’s the simple truth.)
The pain and suffering I endured in trying to get this suite of tools (although with CLISP instead of SBCL) set up and stable in Windows XP is exactly what turned me off of actually following through in my quest to learn and start using LISP. The real stinger is that I actually managed to get it all working smoothly, but by the time I did, I just had no motivation left to actually sink my teeth into the language itself…. And so it all sits installed yet ignored.
At any rate, thanks so much for the guide. I honestly hope to use it someday. But even if I never do, please appreciate my heartfelt thanks on behalf of all the people who really shouldn’t have to suffer through what I did.
If LISP ever begins to descend from its snob-status and actually approach the mainstream, it will be people like you that will make it happen.
Peter says
waterbreath – I’m glad you like it and I’m sorry I didn’t get it to you a year ago! One nice thing about F/OSS is that it does tend to get easier to setup, you just have to either be a year behind on versions or stick to very mature products.
Also, you should keep writing your blog! I loved the piece on Identity Crisis in Computer Science Education and some of the other ones I looked at were good as well. Lots of people are having a similar identity crisis about their career and education (myself included) and prospective students and programmers could use the kind of well thought out, articulate arguments that you’ve demonstrated you can write.
Everyone Else: Go read waterbreath’s blog at Turbulent Intellect, read his good stuff, comment on it, and encourage him to write more!
allen says
Great job!thank u!
I follow your post,and it works.But there is still a problem,i can’t load slime-scratch buffer!
After entering M-x slime-scratch ,emacs says no match ,and nothing happens. I don’t know why.
grg says
Sorry for the noob question, but I get this message in the mini-buffer when I enter ‘M-x slime’: “Searching for program: no such file or directory, lisp”
I’m certain it’s a case of user error, probably with the syntax.
Question 1: in add-to-list, is it `load-path or ‘load-path (back tic or apostrophe)?
Question 2: same thing in require for `slime/’slime
Question 3: Can I use “~/bin/…” instead of “C:\Document and Settings\[USERNAME]\…”? I’ve tried it both ways with the same result.
Peter says
grg: for 1&2, those are apostrophes, not back quotes. Back quotes are used in CL for list construction, usually in macros, while apostrophes are used very often for symbol names (that is in both CL and Emacs Lisp).
As far as the directories, I’ve found only pain when using the Windows default directories. Setting [HOME] as C:\home and following the directory layout in Step 1 is worth the extra effort.
Good luck!
grg says
Thanks, Peter. I’ll try switching it to “c:\home” I’d prefer that, as I’m more accustomed to ‘nix environments, though like many/most people I have to use Windows at work.
I was just trying to “let Windows be Windows” and use the default home directory. I guess I could always just try to set it up in under cygwin if Windows keeps being difficult.
Thanks, again. I appreciate it.
Peter says
grg: Letting Windows be Windows is usually a good idea since it fights back if you try to corner it. Sometimes you have to put your foot down though.
I heard lots of horror stories about using Cygwin versions of Emacs and CLisp together, and I just didn’t want to deal with it. The web was silent about native Emacs and CLisp, so I decided to try out and found it wasn’t too bad at all.
Bruce Lambert says
Peter,
Many thanks for this very useful and well-put-together page. I have installed emacs+slime+clisp many times, and each time it is a time consuming adventure. Like yo uI oftne put it off until I absolutely have to do it. Your page made it much easier this time around. Again thanks.
-bruce
Dan says
When copying and pasting snippets directly from this page, I found I needed to re-type some of the double quote characters which were distinctly different from the double quote character inserted by my keyboard.
Peter says
Dan, that would be WordPress being helpful and giving me angled quote pairs instead of keeping my straight double quotes. I’ll see if I can convince it to cooperate.
Toledo says
Hi, I do have one question (sorry if you answered it before): “Why don’t you try and go with a traditional setup?”
Those wizards sure do use such a setup for a reason.
Mike says
Hi, how to set REPL mode?
Mike says
I could not install SLIME into GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600) a long time.
I find solution (Thank to
John Thingstad) on http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/bd134ae7a422404f : ‘Try Progra~1 instaed of “Program Files” ‘
“The emacs reader is seeing eveything after Program as the next command
line argument.
So it can’t find file “C:\Program”.
On the Bash command line I could write C:/Program\ Files/… but this
doesn’t seem to work in Emacs.
Thus I used the DOS 8.3 long name conversion instead. This is really a
anacronism since no-one uses DOS anymore but it still works. ”
What about it?
CheeseOfSteel says
Thanks! These steps worked on the first try for me. CLISP on the command line is kind of awkward on Windows (it also randomly crashes). Developing with LISP is much more enjoyable now.
benoit says
Thank you!
Texx says
When I use Clisp I am not able to use SLIME-commands M-. or M-, . Any idea what could be wrong with my setup?
Thanks.
John Rigler says
I came to very similar conclusions about lisp-in-a-box and besides if you are crazy enough to try to use lisp, you should be crazy enough at least roll your own environment:
http://deadlycoffee.com/?p=19
q_x says
Great job 🙂 thanks 🙂
Two things:
You could add some tips howto install eg. asdf (or some other tools) to have your guide more comprehensive.
Bad Mzimu changed all your quotation marks/apostrophes in code examples. This could be my browser (but why?) so putting info about not in the trailing comments, but before first code would be something really good. Esp. the ‘ marks were confusing in my case.
Thanks again.
Cheers,
Luke
Carl says
Peter,
Just a note to let you know the links are still active and the installation remains relatively painless in March ’09.
Thanks for these instructions. I continue to enjoy your posts.
Regards
Carl says
Whoops! I just thought my installation was correct.
Emacs and slime are new to me but I coded lisp in the dark ages of punched cards and teletypes. After a few days of enjoying lisp I had a simple little program that seemed like a good vehicle for learning slime. At this point I realized I’d been working from the inferior-lisp repl not the slime-repl.
A long evening of googling and guessing led to:
http://www.cliki.net/SLIME-HOWTO and finally
http://article.gmane.org/gmane.lisp.slime.devel/8129
The second link offered:
The REPL moved to a contrib. Instead of (slime-setup), place
(slime-setup ‘(slime-fancy slime-asdf)) into your ~/.emacs.
I’m not far enough along to know asdf and apparently don’t have it installed so I ended up using:
(slime-setup ‘(slime-fancy)) which properly started slime.
I don’t understand these “incantations” but perhaps others will find them useful.
Carl
liult says
It is so cool. THANKS A LOT!
Andrew says
Thanks, Peter, a variety of your tips got me going. One thing I have NOT solved though is how to read a utf-8 file and display the actual glyphs; any ideas? I’ve tried the obvious, stuff, like setting all the encoding variables to UTF-8, but the best I can do is /124/9875/2309/etc.
If you want to be where the people are, 1/4 of the world’s population wants to program LISP with Chinese…
I’ll keep looking around myself.
thx again
NT says
Thanks, still useful over a year-on and works like a charm!
Ryan says
Peter, thanks a lot for this writeup; it ended a long afternoon of teeth-gnashing. Works great for CLISP 2.48 with one tweak to .emacs: replacing the setq-inferior-lisp-program line with
(setq inferior-lisp-program “[HOME]/bin/clisp/clisp.exe -K full”)
Again, thanks!
ryan says
Peter, thanks a lot. This really helped me out.
Vincent says
Thanks for the writeup, it really helped.
However, I find that I can’t get this to work with CLISP 2.48, even with the change Ryan mentioned (when I try to start SLIME I get a “process inferior-lisp exited abnormally with code 53”). It does work perfectly with 2.47 though. Strange. Anyone have any idea why?
Brian says
I am taking a Junior year programming course at my college and they only use MAC OSs at the school, whereas I’ve been using Windows since I could speak. Having to learn *nix while learning something as jaw-droppingly obscure (compared to C, C++, Java, etc) as LISP seemed like a pipedream to me. Six hours of website digging and I find this beautiful masterpiece. I cannot thank you enough; my grades cannot thank you enough. Now I can actually program in the bloody language without freaking out over how to even get to use it. This is a godsend. A godsend.
Luis says
I am having the same problem as Vincent, what could be the reason of this Code 53 error?
Vincent, did you finally got working CLISP version 2.48 in this setup?
Many thanks
Toni says
Thanks Peter.
Carl’s tip is also worth attention.
Good hacking to all !
Paul says
It’s the kind of problems you had trying to install from scratch and CLISP’s lack of support for ASDF that make me think of using something modern like Python or Java or anything but LISP. At least someone that likes Python works out these problems so noobies can plug and play.
Tony says
I’m using XP, Slime, Emacs, SBCL and I’m having an error based on my misunderstanding of setting the correct path. I’m new to XP and finding the .emacs file in the Applications Data directory was a little strange. My problem has to do with the loading of Slime. In my .emacs I defined the full path name rather than sbcl. Could it be choking on something in the long path?
when I M-x slime
I get
apply: Spawning child process: invalid argument
My .emacs is
(setq inferior-lisp-program “c:/Program Files/Steel Bank Common Lisp/1.0.37/sbcl”)
(add-to-list ‘load-path “c:/Program Files/slime/”)
(require ‘slime)
(slime-setup)
Great blog BTW
MattAttack says
I was using Allegro’s simple Windows friendly one click install lisp-in-a-box until they decided to stop supporting it, which brought me to a couple of hours of slogging to get SLIME running with a different LISP configuration.
You saved me Peter. You’re my hero.
One note on your .emacs incantations however: I had to remove “-ansi -q” before emacs cooperated. But other than that you have probably single handedly helped me live longer healthier life.
Andrew Pennebaker says
I completely agree. I had to go through hell to get a working CLISP/Aquamacs/SLIME/Quicklisp setup on Mac OS X.
If you’re still looking for a good TAR.GZ extractor for Windows, I recommend 7-zip (http://www.7-zip.org/) or PeaZip (http://www.peazip.org/).
Aditya Singh says
Thanks a lot Peter. Just starting off on lisp for the fun of it.
Also, thank you Dan for suggesting retyping of ” when directly copying and pasting the .emacs file entries.
Gishu Pillai says
Walkthrough verified for Win7 (x64) + Emacs v23.2 + CLisp v2.49 + Slime 2011-01-12 snapshot. Thanks a ton!
I had to pay my respects.. thanks Peter for this huge post. Peter Siebel’s book is one I meant to get cracking on for a while.. finally I started on it this year + I ran into LispInABox. Sadly for Win7 on a x64 machine, the REPL loop keeps hanging frequently; and there are no recent releases of it. I had CLisp up and running + but now missed Slime mid-way through the book… More ‘will-sapping’ running from site to site.. And then Google kindly led me to you.