haskell 如何实际使用已经安装的软件包版本,或者找出为什么不可能?

gblwokeq  于 2022-11-14  发布在  其他
关注(0)|答案(1)|浏览(160)

Cabal-newstyle有一个习惯,就是偶尔会无缘无故地从头开始安装,比如说,all 依赖项。对于一个使用lens和其他常见包的项目来说,这可能需要半个小时以上的时间,这是很烦人的,尤其是当目的只是为了快速编译一个可执行文件的一个小修改时,这个可执行文件在一个月前还构建得很好。
Cabal确实提供了一个选项来指定一个约束,比如说,应该使用一个已经全局安装的lens版本。

$ cabal new-run --constraint 'lens installed'
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: my-example-project-0.1.0.0 (user goal)
[__1] next goal: lens (dependency of dat103-Justus-lectures)
[__1] rejecting: lens-5.2, lens-5.1.1, lens-5.1, lens-5.0.1, lens-5,
lens-4.19.2, lens-4.19.1, lens-4.19, lens-4.18.1, lens-4.18, lens-4.17.1,
lens-4.17, lens-4.16.1, lens-4.16, lens-4.15.4, lens-4.15.3, lens-4.15.2,
lens-4.15.1, lens-4.15, lens-4.14, lens-4.13.2.1, lens-4.13.2, lens-4.13.1,
...
lens-0.4, lens-0.3, lens-0.2, lens-0.1 (constraint from command line flag
requires installed instance)
[__1] fail (backjumping, conflict set: my-example-project, lens)
After searching the rest of the dependency tree exhaustively

这是尽管事实上,大量的透镜版本可以找到

$ ls -d ~/.cabal/store/ghc-8.6.4/lens*
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-1392f624ae052009275d5902a574e3f1804a66406a28222f0221cc2211da4f78
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-4854f213f63b67c0e1ea871303590def7a79bce4cc742f658e41dc4c76b56022
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-4caff99c8da3869df1dcfb67181d1be33d98316c3f458f93caedae05279c15e5
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-76531bf275303c15a9e6ae5160ca29f8fb15782d230b2576724103d67a4020d9
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-76a66d74e9cb85066009b345289db97d78bcf441beb12e6b762eb4d197000f19
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-813faecc9a5593fc14ef1677e82b9b384b66de9fff7843635cd7f4e5f4993d16
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-8c724c6d1fcc65ea38dc13fde30d86c4856151b235ef63628b23cee76d2feac5
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-90ec9224b09b828c948a6a1a310a085edc28f92a269bb839a2ac575dc60d579a
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-a157954a3d903fbf6444c054f9b704cab3fc23b36debc16fdc9ee8c0f5c0d5bd
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-c3bf086b6e081a91c7085b3c645652de0c4097edc4c88069203c5f741b14b97f
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-d5dca17dd7dddf6f324313f363ef74ff15d5717011dd750f415ce39942fc703b
/home/js/.cabal/store/ghc-8.6.4/lens-4.19.2-e4a1a8c9f3867cc6e6dc4dc059cc7fc0e4912d9aa4ce5476f63cdea9d3c8535e
/home/js/.cabal/store/ghc-8.6.4/lens-5.0.1-0956efd5ac393e6034c76c4dcc30a40ad1b12ad2b7a708e0f980648bac6287f3
/home/js/.cabal/store/ghc-8.6.4/lens-5.0.1-bfba2b0d59ebb884a2f32a960694c0e44af4fd29a21d8021ebdc42ce994fd055
/home/js/.cabal/store/ghc-8.6.4/lens-5.0.1-ce6c5a7496a674d60f93fae50caa4eb58acc26c6536937cce0f5243238cd6215
/home/js/.cabal/store/ghc-8.6.4/lens-5.0.1-d951ac24c700a8ae7f708a46a084e8fb4b0b008af29e5527f4d8986399248c62
/home/js/.cabal/store/ghc-8.6.4/lens-5.1-08384468083ebbc9d39619bfb59a32b97333acbf703c24bcf3b0bd22357a0115
...

那么,为什么这些没有被使用呢?如何找出阴谋集团甚至认为什么是“安装版本”,以及如何防止安装版本停止使用?

v09wglhw

v09wglhw1#

正如评论中提到的,使用cabal freeze创建一个“冻结文件”是避免“更新波动”的一种方法:
cabalfreeze写出冻结文件,该冻结文件记录由解算器在当前索引和标志下选取的所有版本和标志。
如果您以前没有创建这样的文件,如何避免更新混乱 nowcabal freeze似乎支持以下命令行选项:

--index-state=STATE            Use source package index state as it existed
                                at a previous time. Accepts unix-timestamps
                                (e.g. '@1474732068'), ISO8601 UTC timestamps
                                (e.g. '2016-09-24T17:47:48Z'), or 'HEAD'
                                (default: 'HEAD').

因此,您可以提供一个大约一个月前的日期,并且希望冻结文件将在不考虑该日期之后发布的项目依赖项的任何版本的情况下生成。

相关问题