cabal-version: 3.4
name: SudokuSolver
version: 0.1.0.0
build-type: Simple
library sud
build-depends:
base
, text
hs-source-dirs: lib
exposed-modules: Sud.Rdg
default-language: Haskell2010
executable suSol
default-language: Haskell2010
hs-source-dirs: app
main-is: Main.hs
build-depends:
base
, optparse-applicative
, filepath
, text
当我运行"cabal build "一切都好。然而,当我运行"cabal建立"我得到以下错误:
Could not load module ‘Sud.Rdg’
~
│ It is a member of the hidden package ‘SudokuSolver-0.1.0.0’.
~
│ Perhaps you need to add ‘SudokuSolver’ to the build-depends in your .cabal file.
~
│ Use -v (or `:set -v` in ghci) to see a list of the files searched for.
这就是我有点不知所措的地方,cabal建议我将这个项目本身添加为构建依赖?如果我这样做,我得到:
Error: Dependency on unbuildable package SudokuSolver
| In the stanza 'executable suSol'
| In the inplace package
'SudokuSolver-0.1.0.0'
这对我来说是有意义的,显然你不能把自己添加为构建依赖项。
但是我在这里错过了什么?
编辑:
如果我添加sud
构建依赖和cabal build suSol
我得到:
Resolving dependencies...
cabal: Could not resolve dependencies: [__0] trying:
SudokuSolver-0.1.0.0 (user goal) [__1] unknown package: sud
(dependency of SudokuSolver) [__1] fail (backjumping, conflict set:
SudokuSolver, sud) After searching the rest of the dependency tree
exhaustively, these were the goals I've had most trouble fulfilling:
SudokuSolver, sud
当您向库添加名称时,这意味着它是包的私有或内部库。似乎cabal目前有一个bug,它会导致令人困惑的错误信息,要求您将SudokuSolver
添加到您的可执行文件的构建依赖中,您可以添加SudokuSolver:sud
。
然而,更常见的是保持库未命名(或给它与包相同的名称),这使它成为主要的公共库。然后库的名称与包的名称相同,因此您应该将SudokuSolver
添加到可执行文件的构建依赖项中。这是很长一段时间内唯一可能的选择,内部库相对较新。这可能也是为什么仍然有一些这样的问题。
我还注意到,你可以添加sud
威廉范Onsem说,但只有当你使用cabal-version: 3.0
或更早。对于cabal-version: 3.4
,您必须使用SudokuSolver:sud
(package-name:internal-library-name)表示法。
编辑:我已经在cabal GitHub repo上打开了一个问题。