7
votes

I'm trying to use Haskell Stack to setup a project but using the stack provided ghc I am having a -fPIC error GitHub issue

To bypass the fPIC problem I'm trying to use a package manager provided GHC using the 7.10.3 version (stack currently is using 8.0.2)

When I try to force stack to use the systm ghc it simply ignores me. I've tried to override using /home/user/.stack/config.yaml and {project}/stack.yaml system-ghc : true option... but stack use the 8.0.2 version in the setup.

Am I missing something?

TL;DR

Stack ignore the system-ghc : true option

I'm runnig Sabayon 16


"haskell-primer" is the project name

stack list-dependencies

base 4.9.1.0
ghc-prim 0.5.0.0
haskell-primer 0.1.0.0
integer-gmp 1.0.0.1
rts 1.0
1
I think (not sure) that stack will only use system ghc if dependency resolver finds it suitable. Check if one of your dependencies require ghc8.n. 1.8e9-where's-my-share m.
thx for the comment. I've checked with stack list-dependencies ` stack list-dependencies base 4.9.1.0 ghc-prim 0.5.0.0 haskell-primer 0.1.0.0 integer-gmp 1.0.0.1 rts 1.0`Stefano Cerruti
overriding the resolver INTO the stack.yaml seems to work. I edited it to use lts-6.35 and now it map to the system-ghc. But... I don't know if it's a solution to the problem. I don't want to manually edit all my stack.yaml files...Stefano Cerruti
Why do you need to use the system GHC? Specify your required lts in the stack.yaml file and stack will use whatever version of GHC you require. This is the correct way of picking a specific version of GHC for a specific project.user2407038

1 Answers

16
votes

Setting system-ghc: true allows Stack to use the system GHC if it matches the resolver's constraints. It will not force Stack to use the system GHC if it does not match the constraints. If your resolver requires GHC 8 but your system has GHC 7 then Stack will not use your system GHC no matter what value you give system-ghc. Conversely, if system-ghc: false then Stack will never use the system GHC, regardless of whether its version matches.

From the Stack FAQ, emphasis mine:

If you would like stack to use your system GHC installation, use the --system-ghc flag or run stack config set system-ghc --global true to make stack check your PATH for a suitable GHC by default.

Note that stack can only use a system GHC installation if its version is compatible with the configuration of the current project, particularly the resolver setting.