Reputation: 34071
I have stack installed on my computer for haskell:
Developers-MacBook-Pro:~ developer$ stack ghci
Configuring GHCi with the following packages:
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /private/var/folders/2x/t_2cl03x2092dkzvc702d7lc0000gn/T/ghci2170/ghci-script
Prelude>
As you can see version is still 8.0.1. Then I upgraded the stack as follow:
Developers-MacBook-Pro:~ developer$ stack upgrade
Current Stack version: 1.3.2, available download version: 1.4.0
Newer version detected, downloading
Querying for archive location for platform: osx-x86_64-static
Querying for archive location for platform: osx-x86_64
Downloading from: https://github.com/commercialhaskell/stack/releases/download/v1.4.0/stack-1.4.0-osx-x86_64.tar.gz
Download complete, testing executable
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
New stack executable available at /Users/developer/.local/bin/stack
After I start stack ghci
again and I've got still version 8.0.1, what am I doing wrong?
The image shows, that ghci
version 8.0.2 has successfully installed:
The path is /Users/developer/.stack/programs/x86_64-osx/
Update
In the path /Users/developer/.stack/
, there is a folder called global-project
and I change the yaml as follow:
Now stack ghci run on version 8.0.2:
Developers-MBP:~ developer$ stack ghci
Configuring GHCi with the following packages:
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /private/var/folders/2x/t_2cl03x2092dkzvc702d7lc0000gn/T/ghci526/ghci-script
Upvotes: 4
Views: 6189
Reputation: 359
According to https://docs.haskellstack.org/en/stable/faq/#what-version-of-ghc-is-used-when-i-run-something-like-stack-ghci,
The version of GHC, as well as which packages can be installed, are specified by the resolver.
So, to change the version of GHC used when executing stack ghci
outside stack projects, do:
Find an existing resolver in ~/.stack/build-plan
, e.g. lts-10.4
, or download a new resolver you need;
Execute stack config set resolver lts-10.4
. Yes it updates ~/.stack/global-project/stack.yaml
.
As thus, stack ghci
outside stack projects will use GHC 8.2.2, which is the GHC version specified by resolver lts-10.4
(This relationship can be found at https://www.stackage.org/lts-10.4, or in file ~/.stack/build-plan/lts-10.4.yaml
which says ghc-version: '8.2.2'
).
Upvotes: 4
Reputation: 16635
stack
is a build tool that coordinates building projects with different versions of GHC and sets of dependencies. So you can upgrade stack
independently of ghc.
I'm not quite sure what the expected behavior of stack ghci
is when it's run outside of a project directory. Presumably you con configure the default version of ghc
to use in that case in your ~/.stack/config.yaml
. See: http://docs.haskellstack.org/en/stable/yaml_configuration/
You should also be able to do:
$ stack ghci --with-ghc ghc-7.10.3
But usually the version of ghc is determined by the stackage snapshot you've configured for your project, for instance if you have a stack.yaml
with:
resolver: lts-3.3
...you will be using ghc-7.10.3
Upvotes: 3