The usecase is that I'm having a really hard time testing a fix submitted with Xmobar 0.47.4¹.
I think the reason is that my .cabal file
executable xmobar
build-depends: base
, xmobar
is resulting in picking up 0.47.3, I think because that's the highest tag in the repo at the moment. Indeed,
- if I append
>= 0.47.3to the last line above,cabal building works, - but if I append
> 0.47.3, thencabal buildfails because no version satisfies the constraint.
Now, I could obviously ask the author "can you please push the tag too?" (assuming that is enough for cabal build to find that new version), but I would like to take this difficulty as an opportunity to learn more about Cabal.
Can I express a dependency on a specific commit in an online repository?
This would allow me to use latest changes that have no tag attached, or that are not on the main branch.
Even better, can I express "the library is not online, but it's at
/home/me/where/I/downloaded/the/repoThis, even better, would allow me to easily test local changes to somebody else's repo.
(¹) When using xmobar as a library and with a cabal project around it to allow seamless integration with xmonad (i.e. recompile one recompiles the other, changing either .hs config is picked up when recompiling, and so on; see here for more details). If I ditch all my setup and leave around only my ~/.config/xmobar/xmobar.hs and cabal install from the local copy of xmobar's repo with the most recent commit checked out, I can see the fix.
The
.cabalfile is not the right place for specifying such information: it is associated with a state of the code repository, and shouldn't rely on the presence of any local checkout of other stuff.Instead, you should put the path to the local install in a
cabal.projectfile, namely (in the same directory as your own.cabalfile):Then, when you run any
cabalcommand it will know to use the local version ofXmobarinstead of any version currently on Hackage. You can then use the> 0.47.3constraint in the.cabalfile, and onlyIf only you are working on this project currently, you can simply commit only the
> 0.47.3dependency to your own Git and keep the local version ofXmobarand thecabal.projectfile un-added. It will then be un-compileable for others, but become compileable as soon as Xmobar pushes a new version to Hackage.Alternatively, you can include your forked
Xmobaras a Git submodule into your repo, and add thecabal.projectfile referring to it. Then anybody can check out both your repo and the patched submodule, to build them together.