Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,265
    • Issues 4,265
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16316

Closed
Open
Opened Feb 14, 2019 by Herbert Valerio Riedel@hvr🕺Maintainer

`-package-env=` in OPTIONS_GHC not supported

I just realised we're missing an ingredient in order to support persistent package-environment workflows for standalone scripts:

Consider the following use-cases:


Script requires package environemnts disabled

#!/usr/bin/env runghc
{-# OPTIONS_GHC -package-env=- #-}

main = putStrLn "Hello World"

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:

#!/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).

Trac metadata
Trac field Value
Version 8.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16316