'stack exec' and package clashes

56 views
Skip to first unread message

Sönke Hahn

unread,
Aug 9, 2016, 10:17:35 AM8/9/16
to haskell-stack
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

Harendra Kumar

unread,
Aug 24, 2016, 3:24:17 PM8/24/16
to Sönke Hahn, haskell-stack
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
> --
> 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 haskell-stac...@googlegroups.com.
> To post to this group, send email to haskel...@googlegroups.com.
> 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.

Harendra Kumar

unread,
Aug 24, 2016, 3:26:35 PM8/24/16
to Sönke Hahn, haskell-stack
You may also be interested in this GHC trac issue: https://ghc.haskell.org/trac/ghc/ticket/12518 .

-harendra


-harendra

> To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stack+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages