[plt-scheme] finding the right version of libraries

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Apr 9 02:05:08 EDT 2005

At Fri, 8 Apr 2005 18:29:16 -0600, Phil Windley wrote:
> #!/usr/local/plt/bin/mzscheme -r
> (require (lib "smtp.ss" "net")
>           (lib "head.ss" "net")
>           (lib "xml.ss" "xml")
>           (lib "match.ss")
>           (lib "pregexp.ss"))
> When I start mzscheme as /usr/local/plt/bin/mzscheme (the same command 
> as above) and load this file with (load "..."), it runs perfectly, but 
> when I run it as a script (i.e. just execute it from the shell prompt), 
> I get
> /Applications/PLT Scheme v208/collects/net/compiled/smtp.zo: read 
> (compiled): code compiled for version 208, not 299.100

When you run /usr/local/plt/bin/mzscheme, the Mac OS X supplies
"/usr/local/plt/bin/mzscheme" as the first argument to the MzScheme
binary. Using this full path, MzScheme is able to find the associated
"collects" directory.

But when you run the script, it appears that Mac OS X supplies only
"mzscheme" as the first argument to the MzScheme binary. When MzScheme
gets just "mzscheme", it tries searching your PATH environment variable
to find some "mzscheme" binary. I imagine the v208 "mzscheme" is in
your path, so that's why you get the error above.

The Mac OS X behavior in this case (supplying only "mzscheme" instead
of the full path) seems strange to me. Linux, FreeBSD, and Solaris all
supply the full path in my tests, which is what I would expect.

Unless there's an issue with process identity, I recommend using the
/bin/sh trampoline to avoid this problem:

  #! /bin/sh
  exec /usr/local/bin/mzscheme -qr "$0" ${1+"$@"}
  ; Scheme code starts here


Posted on the users mailing list.