Dustin Ingram

WritingSpeakingGithub

Introduction

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.

Necessary Steps

Download

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 /usr/bin:

$ sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme /usr/bin/scheme

Export

NOTE: Depending on how you’ve already configured Bash, you’ll want to set this variable in one of three places:

  1. ~/.bash_profile
  2. ~/.bash_login
  3. ~/.profile

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 ~/.profile.

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

Reload

Restart your terminal somehow, or simply reload your bash profile:

$ source ~/.profile

Finished

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!

Troubleshooting

“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.