0
votes

What goes into determining the GHC version when using stack?

I thought this would be the resolver but...

I have the following stack file:

resolver: nightly-2018-07-10
packages:
- .

This is what is on Stackage:

Stackage Nightly 2018-07-10 (ghc-8.4.3)
Published on 2018-07-10
View changes
stack resolver: nightly-2018-07-10 

Then I build:

$ stack clean
$ stack build
Building all executables for `PyrethrumPre' once. After a successful build      
of all of them, only specified executables will be rebuilt.
PyrethrumPre-0.1.0.0: configure (exe)
Configuring PyrethrumPre-0.1.0.0...
PyrethrumPre-0.1.0.0: build (exe)
Preprocessing executable 'PyrethrumPre' for PyrethrumPre-0.1.0.0..
Building executable 'PyrethrumPre' for PyrethrumPre-0.1.0.0..
[1 of 2] Compiling MTLPlusLens      ( src\MTLPlusLens.hs, .stack-work\dist  \7d103d30\build\PyrethrumPre\PyrethrumPre-tmp\MTLPlusLens.o )
[2 of 2] Compiling Main             ( src\Main.hs, .stack-work\dist\7d103d30\build\PyrethrumPre\PyrethrumPre-tmp\Main.o )
Linking .stack-work\dist\7d103d30\build\PyrethrumPre\PyrethrumPre.exe ...
PyrethrumPre-0.1.0.0: copy/register
Installing executable PyrethrumPre in C:\PyrethrumPre\.stack-work\install\cd327184\bin

At this point I am expecting GHC to be at 8.4.3 as per the resolver:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2

Why is the GHC version not as expected?

Thanks

1

1 Answers

2
votes

Stack installs the GHC version it needs for your project in a "private" location under ~/.stack, which will not be ghc on your regular $PATH. The ghc version you're seeing is the one installed system-wide (likely by your system's package manager), which Stack ignores by default. To see the version that Stack will actually use to build your project, use stack exec -- ghc --version. stack exec creates a shell context that includes the right version of ghc on the $PATH, among other changes.