Skip to content

register.rkt breaks build in some environments #73

@LiberalArtist

Description

@LiberalArtist

The addition of register.rkt in #72 breaks building Quickscript (as part of the Racket 8.11 release) in Guix, because, in our build environment, the current user's home directory does not exist and cannot be created.

I can work around this by setting PLTUSERHOME or patching out register.rkt (which is what I plan to do, to avoid masking other errors), but, as I've looked into the underlying problem, I don't think register.rkt is really working as intended in any case. The problem is even broader because the documentation recommends this approach:

Here is the code:

;; This is going to be called during setup and will automatically
;; register quickscript-extra in quickscript's library.
(begin-for-syntax
(define-runtime-path script-dir "scripts")
(add-third-party-script-directory! script-dir))

AIUI, it tries to write to library-file as a side-effect when the module register.rkt is visited in the sense of "Module Expansion, Phases, and Visits". Since register.rkt is otherwise unused, the module is visited only when it is compiled by raco setup. But this means that the side-effect only happens for the user who is compiling the module. It seems the side-effect won't happen at all for someone who installed Quickscript as part of a built Racket release.

For scripts distributed as Racket packages, it seems like a better mechanism would be to specify an info.rkt key for packages to define and to use find-relevant-directories.

Some other questionable things I noticed in the process:

  • Assuming PLTQUICKSCRIPTDIR is not set, library-file will be (build-path (find-system-path 'prefs-dir) "quickscript/library.rktd"), so it is shared among all Racket versions and installations. While register.rkt attempts to register a new directory on setup, there seems to be no attempt to clean up on uninstallation—and any such attempt would be unreliable, anyway, since "uninstallation" might mean rm -r.
  • The representation of a library represents paths as strings, which has the usual issues: if serialization is the issue, it seems like byte strings or racket/fasl would be more robust alternatives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions