GHC has two ways to receive package db information i.e. GHC_PACKAGE_PATH and command line options. What you are asking for can be done by passing appropriate command line options but that's not what you are looking for. GHC_PACKAGE_PATH cannot help as it does not provide precise control over package selection.
There is a third way in ghc 8.0.1 which is by creating a package environment file, see https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/packages.html#package-environments. A possibility is to add a feature to stack where it dumps the precise database information with selected package-ids in the environment file. The environment file can then be passed via GHC_ENVIRONMENT env variable. Discussion in https://github.com/commercialhaskell/stack/issues/1957 might be relevant. So it seems what you ask may be possible but will require some work. -harendra On 9 August 2016 at 19:47, Sönke Hahn <[email protected]> wrote: > > Hi all, > > I'm trying to run > > $ stack exec -- sensei-web SomeFile.hs > > in a project with a stack file. (`sensei-web` is a tool that invokes `ghci` to compile code and run test-suites, similar to `ghcid`.) The project adds a custom version of the package `cereal` in its stack file. Unfortunately, I already have the snapshot version of `cereal` installed in my `$HOME/.stack`. Here you can see that I have both packages available: > > $ stack exec -- ghc-pkg list cereal > /home/shahn/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/package.conf.d > /home/shahn/.stack/snapshots/x86_64-linux/lts-6.3/7.10.3/pkgdb > cereal-0.5.2.0 > /home/shahn/project-dir/.stack-work/install/x86_64-linux/lts-6.3/7.10.3/pkgdb > cereal-0.4.1.1 > > I expect the same problem to appear when trying to do e.g.: > > $ stack exec ghci ... > $ stack exec runhaskell ... > $ stack exec doctest ... > $ stack exec ghcid ... > $ stack exec dead-code-detection ... > > Is there a good way to hide `cereal-0.5.2.0`? Either through environment variables or through something in the `.ghci` file in that project? > > Generally it'd be nice if there was a way to let `stack` create an environment, where `ghc` (i.e. `ghc` the executable, `ghci`, `runhaskell` and `ghc` the library) just works. Not sure that's feasible though. > > Thanks for any advice, > Sönke > > -- > You received this message because you are subscribed to the Google Groups "haskell-stack" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-stack/a443f26c-6898-40c3-a07a-54d9e124f9ca%40googlegroups.com . > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "haskell-stack" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-stack/CAPW%2BkkZ5Y_LO24pL6-p%3D0hffNgEu%2BYHBQQqCRLkeiqCOw8%2BXtw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
