通过 stack exec 暴露包

Exposing package through stack exec

我一直在尝试构建和 运行 一个需要访问 ghc 包的应用程序,但我无法设法通过 stack.

公开它

我知道这应该是一个简单的标记 -package ghc 但我如何使用堆栈来做到这一点?

我试过这个: stack exec Engine-exe --package ghc-7.10.3 -- core

我明白了:

Didn't see ghc-7.10.3 in your package indices.
Updating and trying again.
Fetching package index ...remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
Fetched package index.
The following package identifiers were not found in your indices: ghc-7.10.3
Perhaps you meant gc, ghci, ght, or lhc?

我也尝试将其构建为:stack build --ghc-options -package ghc 并得到相同的结果。

如果您的应用程序需要针对 ghc 构建,请将其添加到您的 cabal 文件中的 build-depends。如果您的应用程序需要 运行 ghc 可执行文件,那么它将在 stack exec.

中可见

因此,如果您的项目使用的是 ghc-7.10.3,正确的 ghc 版本应该在 PATH 中。

如果您希望 stack exec 使用与配置不同的解析器或编译器,请执行 stack --resolver lts-6.0stack exec --compiler ghc-7.10.3

我忘了这个!

供日后参考。

最后我所要做的就是ghc-pkg expose ghc