使用带有 extra-deps 的堆栈求解器时发生名称冲突

Hackage name collision while using stack solver with extra-deps

事实证明我的应用程序名称与上传到 hackage 的其中一个软件包相同,所以当我尝试使用 stack solver --resolver lts 7.12 解析额外的依赖项时,我收到以下错误:

$ stack solver --resolver lts-7.12
Using configuration file: stack.yaml
Using cabal packages:
- html-parse.cabal

Using resolver: lts-7.12
Using compiler: ghc-8.0.1
Asking cabal to calculate a build plan...
Trying with packages from lts-7.12 as hard constraints...
Attempt failed.

>>>> Cabal errors begin
cabal.exe: Could not resolve dependencies:
next goal: html-parse (user goal)
rejecting: html-parse-0.2.0.0, 0.1.0.0 (global constraint requires ==0.0.0.3)
trying: html-parse-0.0.0.3
next goal: hunit (dependency of html-parse-0.0.0.3)
Dependency tree exhaustively searched.
<<<< Cabal errors end

Could not parse cabal-install errors:

>>>> Cabal errors begin
cabal.exe: Could not resolve dependencies:
next goal: html-parse (user goal)
rejecting: html-parse-0.2.0.0, 0.1.0.0 (global constraint requires ==0.0.0.3)
trying: html-parse-0.0.0.3
next goal: hunit (dependency of html-parse-0.0.0.3)
Dependency tree exhaustively searched.
<<<< Cabal errors end

我在 .cabal 文件中的 app/package 名称是 html-parse,当前版本是 0.0.0.3。看起来我自己的包被列为具有 ==0.0.0.3 约束的依赖项,但是 hackage 上还有另一个包具有相同的名称但版本不同。

我可以在不重命名我自己的应用程序的情况下以某种方式解决这个问题吗?

引用 Cabal user guide(强调我的):

Package names and versions

All packages have a name, e.g. “HUnit”. Package names are assumed to be unique. Cabal package names can use letters, numbers and hyphens, but not spaces. The namespace for Cabal packages is flat, not hierarchical.

因此,Cabal 库没有处理包名称冲突的功能,cabal-install堆栈。既然如此,您将不得不重命名您的包。

P.S.: 我故意不认真考虑将你的项目设置为使用排除同名包的 private Hackage 的可能性,因为我不知道它会如何发挥在实践中,因为它比它的价值要麻烦得多。