[racket-dev] collects search order

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Fri Dec 12 09:46:24 EST 2014

On Fri, Dec 12, 2014 at 8:46 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> 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"))

I have a couple follow-ups to this answer (which was very helpful for
things I want to do).

If I use a special "config.rktd" file, perhaps like:

    #hash((pkgs-search-dirs . ("/tmp/pkgs" #f)))

so that I can install some packages without affecting the main Racket
installation, what will be different when running `racket -G /tmp/etc`
versus running plain `racket`? In particular, will there be packages,
links, or collections that I can `require` with plain `racket` that I
won't find with `-G /tmp/etc`? I see that the "installation-name" is
different, and the default pkg scope is different, and the result of
`(pkg-config-catalogs)` is now missing
"file:///home/samth/sw/plt/racket/share/pkgs-catalog". Is there
anything else I'll lose? Is the best way to keep this information to
read the original config.rktd, turn paths into absolute paths, and
then add that contents to the new config.rktd that I create?

Sam

Posted on the dev mailing list.