cabal
cabal copied to clipboard
Add --ignore-project to v2-build
E.g. to prevent looking cabal.project somewhere up in the directory tree
This is great. Would be nice for other cabal subcommands as well, i.e. cabal v2-haddock
I'll throw in another vote of support for this feature.
+1
I looked a little bit into it. Quick notes.
-
currently
cabal build --ignore-projectsaysunsupported optionbecause this option is explicitly disabled here:https://github.com/haskell/cabal/blob/dbfce818242544ff6d4d24faf694393544030651/cabal-install/src/Distribution/Client/CmdBuild.hs#L77-L78
-
cabal buildalready useswithContextAndSelectors, which, in turn, useswithProjectOrGlobalConfig, which is aware about--ignore-project(it has a separate parameter for it).
So, it'd seem like an interesting experiment to remove the removeIgnoreProjectOption from the options definition. Well, if you try it, then cabal build --ignore-project gives you a baffling:
Error: cabal: There is no <pkgname>.cabal package file or cabal.project file.
To build packages locally you need at minimum a <pkgname>.cabal file. You can
use 'cabal init' to create one.
in a directory with both a cabal file and a project file. It seems like withContextAndSelectors builds a too simplistic of a context for the --ignore-project branch. It does it with establishDummyProjectBaseContext. Comments around the latter say that it's used to
-- | Create a dummy project context, without a .cabal or a .cabal.project file
No wonder we get the error about no .cabal file (see above). I guess, there has to be a less-dummy project context constructor...
@bacchanalia this code (https://github.com/haskell/cabal/issues/7057#issuecomment-1512316344) intersects with the parts you wrote in the scripts revamp (https://github.com/haskell/cabal/pull/7851). Do you think you could look into supporting --ignore-project for cabal build. I think, properly fixing it may also help in supporting project files for scripts -- something that some people think was a good thing before the revamp.
@ulysses4ever what do you mean by supporting project files for scripts?
@bacchanalia see https://github.com/haskell/cabal/issues/8562#issuecomment-1318269088 and the following discussion
A possible workaround is to use --project-dir=. as described in #10556.
@philderbeast It only works if you don't have a project file in the current directory, which you often do. But that's a fair point.