我正在运行stack
版本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
但是当stack ghci
与GHC.Paths
一起使用时,它会返回错误的路径
$ 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"
我正在运行带有ghc 8.0.1的Arch linux,因此外面没有ghc-7可用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
查看GHC.Paths源代码,我不知道该值的来源。它是ENV变量吗?
{-# 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
正在运行stack exec env
没有看到任何内容。
$ 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
如何修复错误的值?如何配置stack
以使GHC.Paths
返回正确的内容?
UPD
我尝试使用stack
运行--no-system-ghc
并且没有任何区别。
我尝试删除~/.cabal
和~/.stack
个文件夹。我不得不做stack setup
,并且在stack
重新安装编译器之后它没有给我错误的路径,但它并没有给我任何 path,该命令的输出现在为空。
Setup.hs
中的任何一个都没有什么特别的。
答案 0 :(得分:1)
您几乎是对的,GHC_
变量是来自custom Setup.hs
的CPP定义:
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 ]
}
关于错误路径的问题,请尝试运行stack --no-system-ghc ghci
。如果它仍然显示GHC路径的"/usr/bin/ghc-7.10.3"
,那么当您为GHC-7.10.3编译ghc-paths
时,我怀疑你 GHC 1>}和stack
没有重建的东西相当不错,ghc-paths
的旧版本仍然存在。我不知道在快照中重建包的方法,除了whiping ~/.stack
并重新开始之外;这可能是一个好主意。如果你改变了全球GHC的东西。
存在相关问题:Stop using system-ghc silently。