Skip to content

RFC: A new script command #2805

Closed
Closed
@snoyberg

Description

@snoyberg

I've discussed this in some part with various people, so I thought I'd get the thoughts down in writing. Currently, script interpreter usage of Stack has (IMO) three limitations:

  • It's slower than just using runghc directly. Some of that is inherent: it needs to check for the presence of GHC and libraries, for example, which runghc does not. Nonetheless, there is more overhead than necessary. From my understanding, settings file checking is a significant component of this (and also likely something we don't want to impact the behavior of script usage).

  • Scripts violate some reproducibility rules, because:

    • They don't require that a resolver be set
    • They don't require that all packages be listed
    • They can be impacted by other packages installed

    These trade-offs all make sense when considering the runghc feature in general, but are less appetizing when applied to reproducible scripts.

  • There are multiple options that should almost always be set but aren't enforced: --install-ghc, a --resolver as implied above.

Proposal: let's add a new Stack command: stack script. It would have the following semantics:

  • Require that a --resolver be set
  • Hide all packages from the package database except those specified with --package. (Perhaps make an exception for wired in packages, or at the very least base.)
  • Automatically imply --install-ghc
  • Ignore all settings files

As an alternative (or addition) to the above, we could consider:

  • Making these behaviors options available to runghc (e.g., --no-parse-settings-file)
  • Don't actually add a script command, but add support to the script interpreter bits of Stack to recognize a script command and do the right thing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions