如何与cabal-3和ghc也可以是ghc-pkg一起使用?

问题描述

随着cabal-3的发布,来自Hackage的软件包被安装在编译器ghcghc-pkg一无所知的新位置。 换句话说,软件包已安装但未为ghc注册。 Ghcighcghc-pkg无法正常工作。

例如,

cabal install safe --lib

创建文件t1.hs

import Safe

t1 = tailMay [1,2,3]

让我们尝试一下:

> ghci t1.hs
GHCi,version 8.10.2: https://www.haskell.org/ghc/:? for help
[1 of 1] Compiling Main (t1.hs,interpreted)

t1.hs: 1: 1: error:
    Could not find module `Safe '
    Use -v (or `: set -v` in ghci) to see a list of the files searched for.
  |
1 | import Safe
  | ^^^^^^^^^^^
Failed,no modules loaded.

此处描述了此错误

https://github.com/haskell/cabal/issues/6262

在这里

https://gitlab.haskell.org/ghc/ghc/-/issues/17341

我用作设置系统变量的临时解决方案

GHC_PACKAGE_PATH=C:\Users\me\AppData\Roaming\cabal\store\ghc-8.10.2\package.db;

(Windwos 10,巧克力的haskell-dev)

通过 On Windows,packages installed with cabal seem to be unavailable in ghc/ghci

但要进行更新,我将不得不手动更改此系统变量。

对于这个问题还有更好的解决方案吗?

P.S。不幸的是,该解决方案(通过GHC的环境变量GHC_PACKAGE_PATH)与Cabal:(

https://github.com/haskell/cabal/issues/1944

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)