You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cabal build already uses withContextAndSelectors, which, in turn, uses withProjectOrGlobalConfig, 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 (#7057 (comment)) intersects with the parts you wrote in the scripts revamp (#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.
Activity
cohomology commentedon Sep 16, 2020
This is great. Would be nice for other cabal subcommands as well, i.e. cabal v2-haddock
mightybyte commentedon Nov 17, 2021
I'll throw in another vote of support for this feature.
chessai commentedon Apr 14, 2023
+1
ulysses4ever commentedon Apr 18, 2023
I looked a little bit into it. Quick notes.
currently
cabal build --ignore-projectsaysunsupported optionbecause this option is explicitly disabled here:cabal/cabal-install/src/Distribution/Client/CmdBuild.hs
Lines 77 to 78 in dbfce81
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
removeIgnoreProjectOptionfrom the options definition. Well, if you try it, thencabal build --ignore-projectgives you a baffling:in a directory with both a cabal file and a project file. It seems like
withContextAndSelectorsbuilds a too simplistic of a context for the--ignore-projectbranch. It does it withestablishDummyProjectBaseContext. Comments around the latter say that it's used toNo wonder we get the error about no
.cabalfile (see above). I guess, there has to be a less-dummy project context constructor...ulysses4ever commentedon Apr 18, 2023
@bacchanalia this code (#7057 (comment)) intersects with the parts you wrote in the scripts revamp (#7851). Do you think you could look into supporting
--ignore-projectforcabal 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.bacchanalia commentedon Apr 25, 2023
@ulysses4ever what do you mean by supporting project files for scripts?
ulysses4ever commentedon Apr 25, 2023
@bacchanalia see #8562 (comment) and the following discussion
philderbeast commentedon Nov 19, 2024
A possible workaround is to use
--project-dir=.as described in #10556.ulysses4ever commentedon Nov 19, 2024
@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.