Depending on a local package in cabal

╄→尐↘猪︶ㄣ 提交于 2019-11-30 00:30:52

问题


I've written a few packages containing some extra functions for dealing with common types that reflect the way I like to use them (for instance, I prefer to treat Bson documents as maps, rather than lists of fields). I keep these packages in local source directories, not on Hackage.

I would like to introduce dependencies between these packages in their .cabal files, using cabal's build-depends system. But this leads to the following error (bson-docmap being a local module):

cabal: At least the following dependencies are missing:
bson-docmap >=0.0

Is it possible to point cabal to a local directory as an alternate repository?

My current workaround is to keep all my modules in a single local package, but I would prefer to break them apart if possible.


回答1:


If you're using Cabal sandboxes then you can add a local Cabalized directory as a source

cabal sandbox add-source path/to/project/dir

After this point it'll be available for build-depends.




回答2:


You may be able to create a ./cabal.project file with content like:

packages:
  common/
  backend/
  frontend/

And then run $ cabal new-build all.

An example of this can be seen here: https://github.com/ElvishJerricco/reflex-project-skeleton/blob/11c1feb/cabal.project



来源:https://stackoverflow.com/questions/19622809/depending-on-a-local-package-in-cabal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!