
#16316: `-package-env=` in OPTIONS_GHC not supported -------------------------------------+------------------------------------- Reporter: hvr | Owner: (none) Type: feature | Status: new request | Priority: high | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I just realised we're missing an ingredient in order to support persistent package-environment workflows for standalone scripts: Consider the following use-cases: ---- 1. Script requires package environemnts disabled {{{#!hs #!/usr/bin/env runghc {-# OPTIONS_GHC -package-env=- #-} main = putStrLn "Hello World" }}} ---- 2. User manually maintains a package environment for scripts or teaching exercises (this is a quite common way to teach Haskell which I subscribe to, by letting students interact with ghc and ghci directly instead, and only properly introducing `cabal` lateron when it's actually needed) {{{ cabal v2-install --lib lens lens-aeson --package-env=lets-lens }}} and the scripts shall be using that custom named package environment: {{{#!hs #!/usr/bin/env runghc {-# OPTIONS_GHC -package-env=lets-lens #-} import Control.Lens main = do putStrLn "Hello Lens" -- ...lens using code... }}} ---- Currently both of these use-cases don't work because {{{ $ ghci-8.6.3 Main.hs GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help Main.hs:3:16: error: unknown flag in {-# OPTIONS_GHC #-} pragma: -package-env=lets-lens | 3 | {-# OPTIONS_GHC -package-env=lets-lens #-} | ^^^^^^^^^^^^^^^^^^^^^^^^ }}} I do realise that it's tricky to support package-db related commands in `OPTIONS_GHC` but it'd nevertheless be quite important to support this in some way (possibly with some restrictions) in order to properly support the package-env based workflows (NB: the legacy user pkg-db based ones aren't available anymore in future cabal versions -- package-environments have completely replaced the legacy user-pkg db there). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16316 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler