[racket-dev] collects search order

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Dec 12 08:46:56 EST 2014

At Thu, 11 Dec 2014 17:00:14 -0800, Dan Liebgold wrote:
> If I use the -X and -S command line parameters to Racket to make my local
> collects dir the first one searched, it makes it so I can't do (require
> srfi/1).

Yes, this is subtle and confusing.

> Is there something special about the srfi package? (it's layout seems
> different)

The `srfi/1` library is installed as a package, so it's not in the main
"collects" tree. Package paths are registered in "etc/config.rktd".
When that file isn't present or doesn't explicitly list the location of
packages, then the default location is within the "share" directory.
The default location of the "share" directory, in turn, is "../share".

(I'm using paths for an in-place installation; the details vary for a
Unix-style installation, or I may have a detail slightly wrong, but
it's about the same.)

The "../share" path is relative... to what? It turns out that it's
relative to the main "collects" directory. So, when you provide `-X`,
you're also changing the location of package installations.

It may seem odd that the default location of packages (and even the
configuration file) is derived from the main "collects" path, but it's
part of a delicate balance of configuration options that keeps many old
things working, enables `make` in the top-level of the Racket
repository, and so on. The default paths are convenient for some
purposes and inconvenient for others.


To take control of the various paths, create a configuration file as
"config.rktd", and then point Racket at that file's directory using
`-G`. For example, if I copy the "collects" directory of my
installation to "/tmp/collects", then

  racket -X /tmp/collects -l srfi/1

fails, as you say. But if I create "/tmp/etc/config.rktd" with the
content

 #hash((share-dir . "/original/path/to/racket/share"))

then

  racket -X /tmp/collects -G /tmp/etc -l srfi/1

works.


Posted on the dev mailing list.