Skip to content

cabal sdist --project-file doesn't respect the option #7241

Closed

Description

@phadej

cabal-install-3.4 is broken.

cabal-install-3.2 doesn't work either.

Activity

  1. modified the milestone: 3.4.0.0 on Jan 11, 2021
  2. philderbeast commented on Jun 11, 2022

    @philderbeast
    Collaborator

    I'm finding this to be the case with cabal-install-3.8 too.

    > cabal sdist --help
    Generate a source distribution file (.tar.gz).
    
    Usage: cabal sdist [FLAGS] [PACKAGES]
    
    Generates tarballs of project packages suitable for upload to Hackage.
    
    Flags for sdist:
     --project-file=FILE            Set the name of the cabal.project file to
                                    search for in parent directories
     -z, --ignore-project           Ignore local project configuration
    
  3. gbaz commented on Jun 11, 2022

    @gbaz
    Collaborator

    I would have thought this would be resolved by #8109 ?

  4. philderbeast commented on Jun 11, 2022

    @philderbeast
    Collaborator

    Still a problem with cabal I installed with ghcup.

    cabal --version
    cabal-install version 3.8.0.20220526
    compiled using version 3.8.0.20220526 of the Cabal library
    

    I'll install from source and try that too.

  5. Mikolaj commented on Jun 13, 2022

    @Mikolaj
    Member

    This PR is 3.8.0.20220526, as see in release-notes/cabal-install-3.8.0.20220526.md, so I wouldn't count on master branch compiled from source doing any better. However, you could then run relevant tests and see if they behave any different than your use case and, e.g., add a new failing test to include in a new ticket [edit: or this ticket], with a better understanding what the failing scenario is.

  6. philderbeast commented on Jun 15, 2022

    @philderbeast
    Collaborator

    Looking now, which of these branches should I try?

    Screen Shot 2022-06-15 at 12 14 19 PM

  7. Mikolaj commented on Jun 15, 2022

    @Mikolaj
    Member
  8. philderbeast commented on Jun 16, 2022

    @philderbeast
    Collaborator

    I'm on branch cabal-install-v3.8.1.0-rc1. Before I attempt a reproduction I'd like to make sure I understand the help.

    > cabal --version
    cabal-install version 3.8.0.20220526
    compiled using version 3.8.0.20220526 of the Cabal library
    
    > cabal sdist --help
    Generate a source distribution file (.tar.gz).
    
    Usage: cabal sdist [FLAGS] [PACKAGES]
    
    Generates tarballs of project packages suitable for upload to Hackage.
    
    Flags for sdist:
     -h, --help                     Show this help text
     --project-file=FILE            Set the name of the cabal.project file to
                                    search for in parent directories
     -z, --ignore-project           Ignore local project configuration
     -v, --verbose[=n]              Control verbosity (n is 0--3, default
                                    verbosity level is 1)
     --builddir=DIR                 The directory where Cabal puts generated build
                                    files (default dist)
     -l, --list-only                Just list the sources, do not make a tarball
     --null-sep                     Separate the source files with NUL bytes
                                    rather than newlines.
     -o, --output-directory=PATH    Choose the output directory of this command.
                                    '-' sends all output to stdout
    

    --project-file=FILE
    Set the name of the cabal.project file to search for in parent directories

    Can I use this to refer to a project file in the current directory?

    If I set --project-file=foo.project then is the default cabal.project now ignored?

    What are the relative relationships allowed between *.project and *.cabal files? Does a *.project have to be a sibling or parent of all *.cabal files it includes?

    If I set both --project-file=foo.project and --ignore-project then is foo.project ignored. What about cabal.project? If I have one of those too, is that ignored as well?

  9. philderbeast commented on Jun 16, 2022

    @philderbeast
    Collaborator

    Can I use this to refer to a project file in the current directory?

    I find the rendered command line cabal sdist --help unclear but the haddocks are better.

    data ProjectFlags = ProjectFlags
    { flagProjectFileName :: Flag FilePath
    -- ^ The cabal project file name; defaults to @cabal.project@.
    -- The name itself denotes the cabal project file name, but it also
    -- is the base of auxiliary project files, such as
    -- @cabal.project.local@ and @cabal.project.freeze@ which are also
    -- read and written out in some cases. If the path is not found
    -- in the current working directory, we will successively probe
    -- relative to parent directories until this name is found.

  10. philderbeast commented on Jun 16, 2022

    @philderbeast
    Collaborator

    --ignore-project
    Ignore local project configuration

    This is very brief. It is explained more in source comments that don't get surfaced to cabal sdist --help or the haddocks.

    , option ['z'] ["ignore-project"]
    "Ignore local project configuration"
    -- Flag True: --ignore-project is given and --project-file is not given
    -- Flag False: --ignore-project and --project-file is given
    -- NoFlag: neither --ignore-project or --project-file is given

  11. philderbeast commented on Jun 16, 2022

    @philderbeast
    Collaborator

    Here's the latest from the user's guide.

    .. option:: --ignore-project
        
        Ignores the local ``cabal.project`` file and uses the default
        configuration with the local ``foo.cabal`` file. Note that
        if this flag is set while the ``--project-file`` flag is also
        set then this flag will be ignored.
  12. 5 remaining items

  13. gbaz commented on Sep 29, 2022

    @gbaz
    Collaborator

    I tested this on HEAD and it and --ignore-project appear to work. The patch didn't make it into 3.8.1.0 I guess?

    I'll optimistically close on that basis.

  14. gbaz commented on Sep 29, 2022

    @gbaz
    Collaborator

    (note that one needs to run cabal clean between sdist calls to properly test the behavior with different project file flags, as there's some caching of the configuration -- that's probably a separate thing we want to fix)

  15. philderbeast commented on Dec 15, 2023

    @philderbeast
    Collaborator

    I think it focused on --ignore-project and also testing --project-file was hard due to it being set by the testing harness IIUC, so only the standard project files name was tested IIRC.

    @Mikolaj, I was able to use withProjectFile for this:

    withProjectFile :: FilePath -> TestM a -> TestM a
    withProjectFile fp m =
    withReaderT (\env -> env { testCabalProjectFile = fp }) m

  16. Mikolaj commented on Dec 15, 2023

    @Mikolaj
    Member

    In #8226? Good to know, thanks.

  17. philderbeast commented on Dec 15, 2023

    @philderbeast
    Collaborator

    Yes, added today in #8226.

  18. added a commit that references this issue on Apr 22, 2024
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