How do I get cabal to pull the latest from a repository specified in source-repository-package?

84 Views Asked by At

I have included a dependency directly from a local Git repository in my cabal.project file as follows:

packages: .

source-repository-package
  type: git
  location: /home/chris/example/
  tag: master
  subdir: abcxyz

Initially, running cabal build fetched the repository successfully, and the project compiled without issues. However, after updating the repository, I can't seem to find the correct way to make Cabal recognize these updates and fetch the latest commit. There are ways to clear the cache but then I'm deleting additional things and spending more time pulling and building things (which isn't very practical with frequent updates to the external repo).

I've tried rerunning cabal build and cabal update, but it seems Cabal does not check for updates to already fetched Git repositories like the above. I've also had a quick read through https://cabal.readthedocs.io/en/3.4/cabal-project.html but I don't see any mention of such functionality.

How could I do this?

1

There are 1 best solutions below

0
Daniel Wagner On

I expect cabal models tags as being immutable. Of course you and I know there's no way of enforcing this, but it does seem to be a pretty strong convention among git afficionados.

If you plan on updating which commit you want to use frequently, switch from tags to commits:

source-repository-package
  type: git
  location: /home/chris/example/
  commit: deadbeef
  subdir: abcxyz

Then update the commit listed in your cabal.project as needed.

An alternative flow that does not require explicit updates of cabal (but does require explicit updates of git) is to make your other repository into a submodule. In your cabal.project, put something like

packages: . example/abcxyz

then run a command like this:

% git submodule add /home/chris/example example

Of course, if you want to be friendly to your colleagues, you'll need to make the repository available online rather than in /home/chris, and refer to it there. But then this is true both of the source-repository-package approach and of the submodule approach.