Dustin IngramWriting — Speaking — Github
Using MIT-Scheme in MacOS X on the Command LineAugust 01 2012
MIT/GNU Scheme is great, but if
you’re an OSX user, and have a comfortable terminal environment set up, you
might prefer to use
mit-scheme directly from the command line instead of as a
separate OSX application. Since it always takes me a minute to remember the
steps, I figured I’d write it up.
My goal is to be able to run the interactive
mit-scheme shell directly from
the command line in OSX.
Download the MacOS X binary, either
i386 or x86-64 depending on your machine. Mount the
.dmg, and drag the
“MIT/GNU Scheme” icon into the “Applications” folder.
This is the standard install. From here, you can run MIT/GNU Scheme as if it were any other application, but we don’t want that.
Next, symlink the binary to
scheme in your
$ sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme /usr/bin/scheme
NOTE: Depending on how you’ve already configured Bash, you’ll want to set this variable in one of three places:
On load, Bash tries to find your local profiles in that order. If it finds a
file, it won’t load any following profiles. Therefore, you’re going to want to
check to see which, if any, of these files already exist, and append to that
file. For me, this was
Add the library path to your profile:
$ echo "export MITSCHEME_LIBRARY_PATH=\"/Applications/MIT\:GNU\ Scheme.app/Contents/Resources\"" >> ~/.profile
To make it easier for other applications to find the Scheme executable, you can also add the following environmental variable as well:
$ echo "export MIT_SCHEME_EXE=\"/usr/local/scheme\"" >> ~/.profile
Restart your terminal somehow, or simply reload your bash profile:
$ source ~/.profile
You should now be able to run the MIT/GNU Scheme shell directly from the command line:
$ scheme MIT/GNU Scheme running under MacOSX Type `^C' (control-C) followed by `H' to obtain information about interrupts. Copyright (C) 2011 Massachusetts Institute of Technology This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Image saved on Tuesday November 8, 2011 at 10:45:46 PM Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 Edwin 3.116 1 ]=>
And that’s it!
“Can’t find a readable default”
If you’re getting the following error:
$ scheme scheme: can't find a readable default for option --band. searched for file all.com in these directories: /usr/local/lib/mit-scheme-x86-64 Inconsistency detected.
Chances are that you skipped over my note in the “Export” section above. Running
scheme probably ran great for you the first time, but now that some time has
passed and you’ve reloaded your terminal, it doesn’t work!
The problem likely is that the environmental variable linking to scheme’s library is not being loaded because you have multiple Bash profile files. Consolidate your profiles and you should be good to go.