Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

haskell - Difference between "source-repository-package" and "local no-index repositories" in Cabal

I know I can add a local package to a cabal project by listing it in the packages: section of the cabal.project file. The simplest example, which makes a project out of a single local package, is packages: ..

In cabal.project I can also add these two things:

It seems that both of them let me add packages to a project. What's the difference between the two?

(Note: this question is unrelated to the similarly-named source-repository: field, which simply says which is the repository associated to the source code of a package.)

question from:https://stackoverflow.com/questions/65680185/difference-between-source-repository-package-and-local-no-index-repositories

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Only source-repository-package is actually adding a "local package" to your project. It behaves pretty much as listing a package's source folder in packages:, except that the source code is downloaded as needed. In particular, it will be re-downloaded when running cabal build after a cabal clean.

Because it's a local package in your project, other cabal projects are unaware of it. Adding it to other local projects requires recompiling it again.


Meanwhile, local no-index package repositories are repositories in the sense of Hackage or Stackage, only in the local filesystem. They can be specified in both the cabal.project file of an individual project or in the global cabal configuration (~/.cabal/config).

Packages found in these repositories are not considered "local packages" of a project. Their libraries are compiled once and shared between all the projects which are aware of the package repository (which will be all projects, if the repository is listed in ~/.cabal/config). And cabal build after cabal clean will not trigger a recompilation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...