Cabal:仅适用于项目目录中签入的库

Cabal: only work with checked in libraries in project directory

我想将我的 cabal 项目的所有依赖项下载到我的项目 directory/repository 并强制 cabal 永远不要使用 ~/.cabal/ 并且永远不要从互联网下载任何新的依赖项。下载的库应该是系统独立的(不包括本地路径等)。这可能吗?

这背后的想法是,将项目目录复制到安装了相同 ghc 的另一个(离线)系统,它应该开箱即用。

根据 cabal docs,您可以在 cabal.project 或 cabal 文件中设置 active-repositories: none 以将 cabal-install 置于离线模式。

然后,您可以创建 cabal.projectcabal project and try to make all the dependencies that don't come bundled with GHC itself local packages. Clone them in your project folder and add them to the packages: 部分。


上面的问题是 运行 cabal clean 之后需要重新编译 all 包。

作为替代方案,在此处创建一个 local no-index package repository in your offline machine, make it the only available package repository using active-repositories:, and put the sdist tarballs 所有依赖项。

这样依赖项只会被编译一次。