【发布时间】:2020-04-21 10:48:20
【问题描述】:
为了打印出漂亮的垂直树,我搜索了谷歌,找到了一个包pretty-tree。
我想导入这个包,但是问题是:
Stackage LTS 似乎不包含这个包。
所以当我将pretty-tree 添加到package.yaml 和stack build 时,它会提示
In the dependencies for quick-sort-0.1.0.0:
pretty-tree needed, but the stack configuration has no specified version (latest matching version is 0.1.0.0)
needed since quick-sort is a build target.
Some different approaches to resolving this:
* Recommended action: try adding the following to your extra-deps in E:\work-category-theory\quick-sort\stack.yaml:
- pretty-tree-0.1.0.0@sha256:49b0e17008f9d30328db2bcc2958f3a7b78d154d2335c2dbaa2073e237b524ae,668
我将此修订添加到stack.yaml:
extra-deps:
- pretty-tree-0.1.0.0@sha256:49b0e17008f9d30328db2bcc2958f3a7b78d154d2335c2dbaa2073e237b524ae,668
这个问题解决了,我可以编译成功了。
问题是:
-
pretty-tree-0.1.0.0@sha256:49b0e17008f9d30328db2bcc2958f3a7b78d154d2335c2dbaa2073e237b524ae, 688是什么,来自哪里?堆栈文档是这样说的
额外部门
此字段允许您在快照中定义的内容之上指定额外的依赖项(在上述解析器字段中指定)。这些依赖项可能来自本地文件路径或 Pantry 包位置。
对于本地文件路径情况,应用与包相同的相对路径规则。
Pantry 包位置允许您包含来自三种不同来源的依赖项:
黑客攻击
存档(tarball 或 zip 文件,本地或通过 HTTP(S))
Git 或 Mercurial 存储库
但我不知道 Pantry 是什么...
-
还有另一种方法可以解决此问题。 那就是
- 从https://hackage.haskell.org/package/pretty-tree下载pretty-tree-0.1.0.0.tar.gz
- 解压到我的项目文件夹中。
- 将
pretty-tree-0.1.0.0添加到stack.yaml
packages: - . - pretty-tree-0.1.0.0上面这个方法也可以解决问题,但是我的问题是:
我可以将此链接
https://hackage.haskell.org/package/pretty-tree-0.1.0.0/pretty-tree-0.1.0.0.tar.gz直接添加到stack.yaml吗?如:extra-deps: - url: https://hackage.haskell.org/package/pretty-tree-0.1.0.0/pretty-tree-0.1.0.0.tar.gz我试了一下,stack提示错误:
E:\work-category-theory\quick-sort>stack build
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
boxes > using precompiled package
contravariant > using precompiled package
distributive > using precompiled package
th-abstraction > using precompiled package
transformers-compat > using precompiled package
unordered-containers> using precompiled package
pretty-tree > configure
pretty-tree > Configuring pretty-tree-0.1.0.0...
pretty-tree > build
pretty-tree > Preprocessing library for pretty-tree-0.1.0.0..
pretty-tree > Building library for pretty-tree-0.1.0.0..
pretty-tree > [1 of 1] Compiling Data.Tree.Pretty
pretty-tree > copy/register
pretty-tree > Installing library in C:\sr\snapshots\34184208\lib\x86_64-windows-ghc-8.8.3\pretty-tree-0.1.0.0-KT
aQApPwVahHd2AQwQQQSA
pretty-tree > Registering library for pretty-tree-0.1.0.0..
Received ExitFailure 1 when running
Raw command: "C:\\Users\\Chansey\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.8.3\\bin\\ghc-pkg.exe" --user -
-no-user-package-db --package-db "C:\\sr\\snapshots\\34184208\\pkgdb" describe --simple-output distributive --expand-pkg
root
Standard error:
ghc-pkg.exe: C:\sr\snapshots\34184208\pkgdb\th-abstraction-0.3.2.0-D5zRQZUNFcq6kU1WHIrSvs.conf: getModificationTime:Crea
teFile "\\\\?\\C:\\sr\\snapshots\\34184208\\pkgdb\\th-abstraction-0.3.2.0-D5zRQZUNFcq6kU1WHIrSvs.conf": does not exist (
The system cannot find the file specified.)
Progress 7/15
对不起,由于我对 Haskell 生态系统不是很熟悉,这个问题可能很愚蠢。
谢谢。
编辑:
我发现如果我第一次使用
extra-deps:
- pretty-tree-0.1.0.0@sha256:49b0e17008f9d30328db2bcc2958f3a7b78d154d2335c2dbaa2073e237b524ae,668
然后回滚到
extra-deps:
- url: https://hackage.haskell.org/package/pretty-tree-0.1.0.0/pretty-tree-0.1.0.0.tar.gz
错误消失了,但我不知道为什么...
【问题讨论】:
-
您为什么要这样做?添加
pretty-tree-0.1.0.0是执行此操作的完美方式。 -
@Erich 因为对 Haskell 生态不熟悉,所以想了解一下最佳实践。
-
好的,那我告诉你,添加
pretty-tree-0.1.0.0是最好的做法。 -
是的,恕我直言,这是最好的方法。
-
@chansey 它是 Stack 的内部组件,用于指定包版本。有关详细信息,请参阅the documentation。
标签: haskell haskell-stack hackage stackage