scmutils on Mac OS X
 

These are instructions to run MIT-Scheme, including the scmutils library, on Mac OS X. MIT-Scheme plus scmutils is necessary to work with the book "Structure and Interpretation of Classical Mechanics," by G.J. Sussman and J. Wisdom, with M.E. Mayer. I only have personal experience with an Intel Mac, but I believe that these instructions will work with older G4 or G5 Macs as well, and can probably also be appropriately modified to work with Windows machines.

1. Download the appropriate binaries (Intel or PPC) of MIT Scheme for Mac OS X here.

2. Follow the instructions here to unpack the your MIT Scheme distribution and put the executable files and library files where you want them, so long as the executables are on your path (I put the executables in /usr/local/bin and the library files in /usr/local/lib/mit-scheme). 

If you have administrative privileges on your machine, but are told that you do not have permission to execute commands that put stuff in /usr/local, put “sudo” in front of the command that you need to execute. E.g., I downloaded the file mit-scheme-20070909-ix86-apple-darwin.tar.gz onto my desktop, unpacked it there, and then executed

> cd ~/Desktop/mit-scheme-20070909-ix86-apple-darwin

> sudo mv bin/* /usr/local/bin/.

> sudo mv lib/mit-scheme /usr/local/lib/.

You should now test that MIT Scheme works by opening a terminal and typing

> scheme –-library /usr/local/lib/mit-scheme

You can exit by entering typing “(exit)” at the prompt.

3. Go here and download scmutils for Linux (Sarge version).

4. Now, unpack scmutils-200609-06-ix86-gnu-linux-sarge.tar.gz, but don’t put the contents in /usr/local/scmutils like the instructions on the download page say. Put it somewhere where you don’t need root access to manipulate it; otherwise you’ll run into trouble compiling at the next step. I put the .tar.gz file on my desktop, and then just unarchived it there, so I had a directory at ~/Desktop/scmutils-20060906-ix86-gnu-linux-sarge/.

5. Change directories to the /scmutils/src directory inside your unpacked directory, and run MIT Scheme using the –-compiler and –-library flags (you'll need to compile some files) like this:

> cd ~/Desktop/scmutils-20060906-ix86-gnu-linux-sarge/scmutils/src

> scheme –-library /usr/local/lib/mit-scheme –-compiler

6. We're going to follow some instructions that I found here. At the scheme prompt, type the following:

1 ]=> (load “compile.scm”)

The system should respond by compiling the .scm files. You’ll get a lot of warnings. I'm not sure whether any are important, but in any case, things seem to work, so don’t worry--be happy.

When it’s done, repeat the command (load "compile.scm"), and it should respond with cleaner messages that look like

;Loading “compile.scm”…
; Loading “general/comutils.com”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”…
; Loading “syntax.com”… done
; Loading “rule-syntax.com”… done
; … done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”…
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; … done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
; Loading “compile.scm”… done
;… done
;Unspecified return value

Now type the following command:

1 ]=> (load “load.scm”)

and the system should respond with a large number of successful loads.

You now have the entire scmutils library loaded and working inside MIT-Scheme. We want to save an image of your working environment, so type:

1 ]=> (disk-save “mechanics.band” “SICM”)

The system will respond with

;Unspecified return value

but it will also create a large file in your current directory (the ~/Desktop/scmutils-20060906-ix86-gnu-linux-sarge/scmutils/src directory if you've been following instructions) called “mechanics.band” that is an image of the environment. You can type (exit) and kill the MIT-scheme process.

7. Let’s now move the scmutils directory to its permanent location. I’ll put it in /usr/local/scmutils:

> cd ~/Desktop/scmutils-20060906-ix86-gnu-linux-sarge

> sudo mv scmutils /usr/local

8. We’re not going to use the “mechanics” shell script that came with the scmutils download (in the /bin directory). That script is there to start up MIT-Scheme in the "edwin" editor, which is an Emacs-like editor. I couldn't get that to work; instead we'll run MIT-Scheme in Emacs itself. 

First we'll write a small shell script of our own, called "mech-scheme," so copy and save the following into a file of that name using the editor of your choice:

#!/bin/sh

SCHEME=mit-scheme
MECH_BAND=/usr/local/scmutils/src/mechanics.band
CMD="${SCHEME} -band ${MECH_BAND}"

exec ${CMD}


9. You'll need to make mech-scheme executable and then it's convenient to put it in /usr/local/bin:

> chmod +x mech-scheme

> sudo mv mech-scheme /usr/local/bin

10. Now you should be able to run MIT-Scheme, with the scmutils library loaded, by just typing

> mech-scheme

NOTE: You should do that, and notice that when an error occurs (e.g. if you type in "(5)" at the prompt), the system no longer recognizes "(RESTART 1)" to get back to the prompt; it complains that RESTART is an unbound variable. You should type "(restart 1)" without the caps, instead. I don't know what causes this change in behavior. [Typing Ctrl-c twice also gets you back to the prompt.]

11. It's easier to use MIT-scheme from within Emacs than from the terminal. (By the way, I use Carbon Emacs, which I find to behave in a much more standard way than Aquamacs.) You should first download quack.el, which makes it much more convenient to run Scheme within Emacs, and put it in a place on your Emacs path (e.g. I put it in /Applications/Emacs.app/Contents/Resources/site-lisp), and add the line

(require 'quack)

to your .emacs file. Now if you quit and re-open emacs, and then type "M-x run-scheme", (M-x will either be alt-x or cmd-x) it will ask you which Scheme you want to run. Respond "mech-scheme", and you'll be running MIT-Scheme with scmutils pre-loaded, inside Emacs. You can change the quack defaults so that mech-scheme is your default Scheme.

Click here to return to Nerd Wisdom