[Haskell-beginners] How to install new GHC ?

Francesco Ariis fa-ml at ariis.it
Tue Dec 12 13:18:50 UTC 2017


On Tue, Dec 12, 2017 at 02:53:47PM +0200, Baa wrote:
> @Francesco: unfortunately nightly misses some package. So, I tried:
> 
>   $ stack --resolver=ghc-8.2.2 setup --reinstall
>   Preparing to install GHC (tinfo6) to an isolated location. This will not
>   interfere with any system-level installation. Already downloaded.                       
>   Installed GHC.
> 
>   stack will use a sandboxed GHC it installed
>   For more information on paths, see 'stack path' and 'stack exec env'
>   To use this GHC and packages outside of a project, consider using:
>   stack ghc, stack ghci, stack runghc, or stack exec
> 
> So seems that 8.2.2 was installed, right? But how to build the project
> with new GHC now? I never used cabal before, `stack ghci` still runs
> 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not correspond
> to .yaml file LTS - maybe this is a reason why old 8.0.2 is stil used...
> 
> When I try cabal build/new-build/repl I get:
> 
>   cabal: The program 'ghc' version >=6.4 is required but it could not be
>   found.
> 
> So, cabal does not know about installed GHC versions (at least 8.0.2,
> used by stack). I tried --require-sandbox but without success.

Hey Paul,
    four-step plan:

1. check where stack installed ghc, it should be something like:

    ~/.stack/programs/x86_32-linux/ghc-nopie-8.2.1/lib/ghc-8.2.1/bin

2. add these two lines to your `~/.bashrc`:

    export PATH=~/.cabal/bin:$PATH   # path to stuff built with cabal
    export PATH=~/the.stackpathabove:$PATH # path to ghc

3. check the right ghc version has been selected:

    ghc -v
    # should be 8.2.2

4. cd into your project and `cabal new-build` and then open a repl on it
   with `cabal new-repl`.

Let us know if this works!



More information about the Beginners mailing list