Depending on a local package in cabal
Asked Answered
A

3

24

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.

Acinaciform answered 27/10, 2013 at 19:58 Comment(1)
Just install the bson-docmap package. Once it's installed, cabal doesn't care about its origin.Rubeola
N
20

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.

Nissensohn answered 27/10, 2013 at 20:12 Comment(2)
What if I'm not?Guileless
cabal does not have a sandbox subcommand anymoreStupefy
P
10

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

Praetor answered 21/3, 2018 at 23:23 Comment(0)
J
2

In your cabal.project file add a new section:

source-repository-package
  type: git
  -- Normally this is a git URL, but a local path works too (but I think it must be absolute?):
  location: /path/to/your/local/bson-docmap
  -- Replace this with the commit you want to check out:
  tag: e1a47b8802d12cd221eead508c5b4d9ccd65feb4

[Note that source-repository-package is a keyword, not the name of the package you're referring to.]

Jackofalltrades answered 8/1, 2022 at 21:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.