0

I am running stack version 1.1.2 x86_64 hpack-0.14.1

$ stack exec which ghc
Run from outside a project, using implicit global project config
Using resolver: lts-5.10 from implicit global project's config file: /home/wisut/.stack/global-project/stack.yaml
/home/wisut/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc

but when using stack ghci with GHC.Paths it is return the wrong path

$ stack ghci
Run from outside a project, using implicit global project config
Using resolver: lts-5.10 from implicit global project's config file: /home/wisut/.stack/global-project/stack.yaml
Error parsing targets: The specified targets matched no packages. Perhaps you need to run 'stack init'?
Warning: build failed, but optimistically launching GHCi anyway
Configuring GHCi with the following packages: 
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
Ok, modules loaded: none.
Prelude> GHC.Paths.ghc
"/usr/bin/ghc-7.10.3"

I am running Arch linux with ghc 8.0.1 therefor there is no ghc-7 avaliable outside stack

[wisut@earth ~]$ which ghc
/usr/bin/ghc
[wisut@earth ~]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.1
[wisut@earth ~]$ ls -al /usr/bin/ghc
lrwxrwxrwx 1 root root 9 May 24 18:28 /usr/bin/ghc -> ghc-8.0.1

Looking at GHC.Paths source, I have no idea where the value are from. Is it the ENV vars?

{-# LANGUAGE CPP #-}

module GHC.Paths (
        ghc, ghc_pkg, libdir, docdir
  ) where

libdir, docdir, ghc, ghc_pkg :: FilePath

libdir  = GHC_PATHS_LIBDIR
docdir  = GHC_PATHS_DOCDIR

ghc     = GHC_PATHS_GHC
ghc_pkg = GHC_PATHS_GHC_PKG

Running stack exec env didn't see anything.

$ stack exec env | grep -i ghc
Run from outside a project, using implicit global project config
GHC_PACKAGE_PATH=/home/wisut/.stack/global-project/.stack-work/installx86_64-linux/lts-5.10/7.10.3/pkgdb:/home/wisut/.stack/snapshots/x86_64-linux/lts-5.10/7.10.3/pkgdb:/home/wisut/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/package.conf.d
PATH=/home/wisut/.stack/global-project/.stack-work/install/x86_64-linux/lts-5.10/7.10.3/bin:/home/wisut/.stack/snapshots/x86_64-linux/lts-5.10/7.10.3/bin:/home/wisut/.stack/programs/x86_64-linux/ghc-7.10.3/bin:/home/wisut/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

How can I fix the wrong value? How to to config stack to make GHC.Paths return the correct one?

UPD I tried running stack with --no-system-ghc and it didn't make any difference. I tried to remove my ~/.cabal and ~/.stack folders. I had to do stack setup, and after stack re-installed the compiler it doesn't give me that wrong path, but it doesn't give me any path, the output of that command is now empty. I have nothing special in any of Setup.hs too.

Alexey Raga
  • 7,457
  • 1
  • 31
  • 40
wizzup
  • 2,361
  • 20
  • 34

1 Answers1

1

You are almost right, the GHC_ variables are CPP definitions coming from custom Setup.hs:

let buildinfo = emptyBuildInfo{
         cppOptions = ["-DGHC_PATHS_GHC_PKG=" ++ show c_ghc_pkg,
                       "-DGHC_PATHS_GHC=" ++ show c_ghc,
                       "-DGHC_PATHS_LIBDIR=" ++ show libdir,
                       "-DGHC_PATHS_DOCDIR=" ++ show docdir ]
       }

About your problem with wrong path, try to run stack --no-system-ghc ghci. If it still shows "/usr/bin/ghc-7.10.3" for GHC paths, then I suspect that you had GHC there when you compiled ghc-paths for GHC-7.10.3, and as stack is quite good in not rebuilding stuff, the old version of ghc-paths is still there. I don't know a way to rebuild a package in a snapshot, other then whiping ~/.stack and starting over; which might be a good idea. if you changed you global GHC stuff.

There is a related issue: Stop using system-ghc silently.

phadej
  • 11,947
  • 41
  • 78
  • 1
    To force stck to rebuild a package - have a look at: http://stackoverflow.com/a/37237777/866915 – ErikR Jun 29 '16 at 13:26
  • I tried with `--no-system-ghc` and it doesn't make any difference. I tried to remove my `~/.cabal` and `~/.stack` folders and after `stack` re-installed the compiler it doesn't give me that wrong path, but it doesn't give me _any_ path, the output of that command is now empty. I have nothing special in any of `Setup.hs` either. – Alexey Raga Jan 14 '17 at 09:49