I want to create a Cabal project with the possibility to include multiple packages in the same project. When I read Cabal documentation, it says that one has to create a "cabal.project" file. Is this file created manually into the project root or is there a command to create it? The documentation says that all modifications shall be made in the "cabal.project.local" file. How this file is created? Does this mean that to create a cabal project with multiples packages one has to have a "cabal.project" file and a "cabal.project.local" file in the same project root? Thanks.
1 Answers
Don't overthink this. A cabal.project
file is mostly just listing some packages that you want to build together as a unit, instead of pulling them from Hackage. So yeah, simply create it manually.
What the docs mean by ‘all modifications shall be made in the "cabal.project.local" file’ is that the cabal.project
should specify what is always needed to build the project (e.g. packages that simply aren't on Hackage at all, but are included in your repo either directly or as Git submodules), whereas if you just make some tweaks (e.g. experimentally testing out what needs to be changed so your package will compile with a new version of some 3rd-party dependency, which you've checked out locally before considering to file a pull request or to fork it into your own repo) then this should go in the cabal.project.local
file. But honestly, you could as well make the changes in cabal.project
and then simply not git add
them†.
IMO all actually important information to make the package future-proof should reside in the packagename.cabal
file and/or a stack.yaml
file, not in cabal.project
.
†The danger here is that it's easy to accidentally commit changes that were only meant to be local to already-VCS'd files. I always use git add -p
so that I review any changes I'm adding, before committing.

- 117,950
- 5
- 174
- 319
-
Thanks for the answer. I am new to cabal and the Haskell world. So the file extension to "cabal.project" does not matter? I mean if one can have "cabal.project.txt" (i.e. a text file). – ezyman Feb 16 '22 at 18:00
-
@ezyman The extension matters. The file must have the exact name `cabal.project`. – Daniel Wagner Feb 16 '22 at 20:47
-
@DanielWagner well, or the exact name `cabal.project.local`. – leftaroundabout Feb 16 '22 at 22:53