Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --ignore-project to v2-build #7057

Open
phadej opened this issue Sep 11, 2020 · 9 comments
Open

Add --ignore-project to v2-build #7057

phadej opened this issue Sep 11, 2020 · 9 comments

Comments

@phadej
Copy link
Collaborator

phadej commented Sep 11, 2020

E.g. to prevent looking cabal.project somewhere up in the directory tree

@phadej phadej self-assigned this Sep 11, 2020
@phadej phadej added this to the 3.6.0.0-rc1 milestone Sep 11, 2020
@cohomology
Copy link

This is great. Would be nice for other cabal subcommands as well, i.e. cabal v2-haddock

@mightybyte
Copy link
Collaborator

I'll throw in another vote of support for this feature.

@chessai
Copy link
Member

chessai commented Apr 14, 2023

+1

@ulysses4ever
Copy link
Collaborator

I looked a little bit into it. Quick notes.

  • currently cabal build --ignore-project says unsupported option because this option is explicitly disabled here:

    , commandOptions = removeIgnoreProjectOption
    . nixStyleOptions (\showOrParseArgs ->

  • 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...

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented 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-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.

@bacchanalia
Copy link
Collaborator

@ulysses4ever what do you mean by supporting project files for scripts?

@ulysses4ever
Copy link
Collaborator

@bacchanalia see #8562 (comment) and the following discussion

@philderbeast
Copy link
Collaborator

A possible workaround is to use --project-dir=. as described in #10556.

@ulysses4ever
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests