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

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

Closed
phadej opened this issue Jan 11, 2021 · 19 comments
Closed

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

phadej opened this issue Jan 11, 2021 · 19 comments

Comments

@phadej
Copy link
Collaborator

phadej commented Jan 11, 2021

cabal-install-3.4 is broken.

cabal-install-3.2 doesn't work either.

@philderbeast
Copy link
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

@gbaz
Copy link
Collaborator

gbaz commented Jun 11, 2022

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

@philderbeast
Copy link
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.

@Mikolaj
Copy link
Member

Mikolaj commented Jun 13, 2022

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.

@philderbeast
Copy link
Collaborator

Looking now, which of these branches should I try?

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

@Mikolaj
Copy link
Member

Mikolaj commented Jun 15, 2022

We haven't broken master branch yet, I trust. But you can also use https://github.com/haskell/cabal/tree/cabal-install-v3.8.1.0-rc1 for extra safety.

@philderbeast
Copy link
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?

@philderbeast
Copy link
Collaborator

philderbeast commented Jun 16, 2022

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.

@philderbeast
Copy link
Collaborator

philderbeast commented Jun 16, 2022

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

@philderbeast
Copy link
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.

@philderbeast
Copy link
Collaborator

With #8226 I've added a minimal reproduction of the set up I had where I noticed this problem.

For the backstory, I squished a set of packages into one package (using public sub-libraries) and ended up with two projects, cabal.project for building the loose set of packages and cabal.sublib.project for building a single package with its *.cabal file in the root folder. All the loose package *.cabal files were in subdirectories.

I'm not sure how to wire the files I've added into a test suite. Any pointers about where to start?

@Mikolaj
Copy link
Member

Mikolaj commented Jun 20, 2022

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

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
Copy link
Member

Mikolaj commented Jun 20, 2022

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

yes

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

yes

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?

parent re directory structure

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?

I don't know. Probably both. #8109 is about that. Perhaps it's described there? It got reviewed, so the semantics assumed there may be fine.

@Mikolaj
Copy link
Member

Mikolaj commented Jun 20, 2022

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

Right, this needs to be documented better.

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

Please kindly verify it agrees with #8109.

@gbaz
Copy link
Collaborator

gbaz commented Sep 29, 2022

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.

@gbaz gbaz closed this as completed Sep 29, 2022
@gbaz
Copy link
Collaborator

gbaz commented Sep 29, 2022

(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)

philderbeast added a commit to cabalism/cabal that referenced this issue Dec 15, 2023
philderbeast added a commit to cabalism/cabal that referenced this issue Dec 15, 2023
@philderbeast
Copy link
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

@Mikolaj
Copy link
Member

Mikolaj commented Dec 15, 2023

In #8226? Good to know, thanks.

@philderbeast
Copy link
Collaborator

Yes, added today in #8226.

philderbeast added a commit to cabalism/cabal that referenced this issue Dec 29, 2023
philderbeast added a commit to cabalism/cabal that referenced this issue Jan 8, 2024
philderbeast added a commit to cabalism/cabal that referenced this issue Jan 14, 2024
philderbeast added a commit to cabalism/cabal that referenced this issue Jan 17, 2024
philderbeast added a commit to cabalism/cabal that referenced this issue Jan 20, 2024
philderbeast added a commit to cabalism/cabal that referenced this issue Jan 20, 2024
- Move project sdist tests to cabal-testsuite
- Add --ignore-project test
- Duplicate tests but without cabal.project
- Add a cabal.project one folder up
- Add a package Z in the root
- Rerun --accept with more immediate parent project
- Add a readme for the tests
- Fix problems with uv package, update expected output
- Add U and V modules
- Explain what is wrong with cabal.dot-uv.test.hs
- Add a note on cabal.no-project.test.hs
- Explain what is wrong with cabal.sub-pq.test.hs
- Explain what is wrong with cabal.sub-rs.test.hs
- Explain what is wrong with cabal.dot-uv.test.hs
- Leave a note explaining cabal.no-project.test.hs
- Leave a note explaining cabal.project.test.hs
- Leave a note explaining cabal.sub-pq.test.hs
- Explain what is wrong with cabal.sub-rs.test.hs
- Patches for project respecting behaviour
- Explain root ignore-project and no-project tests
- Add *.v2.test.hs variants exercising v2-sdist
- Add v2 patches, test out not using <ROOT>
erikd pushed a commit to erikd/cabal that referenced this issue Apr 22, 2024
- Move project sdist tests to cabal-testsuite
- Add --ignore-project test
- Duplicate tests but without cabal.project
- Add a cabal.project one folder up
- Add a package Z in the root
- Rerun --accept with more immediate parent project
- Add a readme for the tests
- Fix problems with uv package, update expected output
- Add U and V modules
- Explain what is wrong with cabal.dot-uv.test.hs
- Add a note on cabal.no-project.test.hs
- Explain what is wrong with cabal.sub-pq.test.hs
- Explain what is wrong with cabal.sub-rs.test.hs
- Explain what is wrong with cabal.dot-uv.test.hs
- Leave a note explaining cabal.no-project.test.hs
- Leave a note explaining cabal.project.test.hs
- Leave a note explaining cabal.sub-pq.test.hs
- Explain what is wrong with cabal.sub-rs.test.hs
- Patches for project respecting behaviour
- Explain root ignore-project and no-project tests
- Add *.v2.test.hs variants exercising v2-sdist
- Add v2 patches, test out not using <ROOT>
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

5 participants