Skip to content

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

Open

Description

@phadej

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

Activity

  1. self-assigned this
    on Sep 11, 2020
  2. added this to the 3.6.0.0-rc1 milestone on Sep 11, 2020
  3. cohomology commented on Sep 16, 2020

    @cohomology

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

  4. mightybyte commented on Nov 17, 2021

    @mightybyte
    Collaborator

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

  5. added
    re: --ignore-project
    on Aug 20, 2022
  6. chessai commented on Apr 14, 2023

    @chessai
    Member

    +1

  7. ulysses4ever commented on Apr 18, 2023

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

  8. ulysses4ever commented on Apr 18, 2023

    @ulysses4ever
    Collaborator

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

  9. bacchanalia commented on Apr 25, 2023

    @bacchanalia
    Collaborator

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

  10. ulysses4ever commented on Apr 25, 2023

    @ulysses4ever
    Collaborator

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

  11. philderbeast commented on Nov 19, 2024

    @philderbeast
    Collaborator

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

  12. ulysses4ever commented on Nov 19, 2024

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions