`GHC.Paths.*` 值的来源是哪里?
Where is the source of `GHC.Paths.*` value came from?
我是运行stack
版本1.1.2x86_64hpack-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
一起使用时,它是 return 错误的路径
$ 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"
我是 运行 Arch linux,使用 ghc 8.0.1,因此 stack
之外没有可用的 ghc-7
[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 来源,我不知道价值来自哪里。是环境变量吗?
{-# 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
return 正确?
UPD
我用 运行 stack
和 --no-system-ghc
试过,但没有任何区别。
我试图删除我的 ~/.cabal
和 ~/.stack
文件夹。我不得不做 stack setup
,在 stack
重新安装编译器后它没有给我错误的路径,但它没有给我 any路径,该命令的输出现在为空。
Setup.hs
我也没什么特别的。
你几乎是对的,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,并且 stack
在不重建东西方面相当不错,旧版本的 ghc-paths
仍然存在。我不知道在快照中重建包的方法,除了鞭打 ~/.stack
并重新开始;这可能是个好主意。如果您更改了全局 GHC 内容。
有一个相关问题:Stop using system-ghc silently。
我是运行stack
版本1.1.2x86_64hpack-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
一起使用时,它是 return 错误的路径
$ 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"
我是 运行 Arch linux,使用 ghc 8.0.1,因此 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 来源,我不知道价值来自哪里。是环境变量吗?
{-# 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
return 正确?
UPD
我用 运行 stack
和 --no-system-ghc
试过,但没有任何区别。
我试图删除我的 ~/.cabal
和 ~/.stack
文件夹。我不得不做 stack setup
,在 stack
重新安装编译器后它没有给我错误的路径,但它没有给我 any路径,该命令的输出现在为空。
Setup.hs
我也没什么特别的。
你几乎是对的,GHC_
变量是来自 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 ]
}
关于你的路径错误问题,尝试运行stack --no-system-ghc ghci
。如果它仍然为 GHC 路径显示 "/usr/bin/ghc-7.10.3"
,那么我怀疑当你为 GHC-7.10.3 编译 ghc-paths
时,你 有 GHC,并且 stack
在不重建东西方面相当不错,旧版本的 ghc-paths
仍然存在。我不知道在快照中重建包的方法,除了鞭打 ~/.stack
并重新开始;这可能是个好主意。如果您更改了全局 GHC 内容。
有一个相关问题:Stop using system-ghc silently。