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 freeze qualifies all package constraints with any #9799

Open
alt-romes opened this issue Mar 11, 2024 · 1 comment · May be fixed by #9811
Open

Cabal freeze qualifies all package constraints with any #9799

alt-romes opened this issue Mar 11, 2024 · 1 comment · May be fixed by #9811

Comments

@alt-romes
Copy link
Collaborator

I was trying to add private-dependencies (#4035, wip at #9743) support to cabal freeze.

It looks like the constraints populating the freeze file for every package always use the any qualifier. Here's an example of a package in the testsuite:

active-repositories: test-local-repo:merge
constraints: any.array ==0.5.6.0,
             any.base ==4.19.0.0,
             any.binary ==0.8.9.1,
             any.bytestring ==0.12.0.2,
             any.containers ==0.6.8,
             any.deepseq ==1.5.0.0,
             any.directory ==1.3.8.1,
             any.exceptions ==0.10.7,
             any.filepath ==1.4.100.4,
             any.ghc-bignum ==1.3,
             any.ghc-boot-th ==9.8.1,
             any.ghc-prim ==0.11.0,
             any.lib01 ==0.1.0.0 || ==0.2.0.0,
             any.mtl ==2.3.1,
             any.pretty ==1.1.3.6,
             any.process ==1.6.18.0,
             any.rts ==1.0.2,
             any.stm ==2.5.2.1,
             any.template-haskell ==2.21.0.0,
             any.time ==1.12.2,
             any.transformers ==0.6.1.0,
             any.unix ==2.8.3.0
index-state: HEAD

I think that this design is incompatible with private dependencies, because any qualified package constraints will apply to all scopes (be them the top-level scope, setup-component scopes, independent goals, or private scopes...).

Is there any reason for this being so?
I believe the right way forward here is to properly qualify the packages in the freeze file according to their qualifier in the package. This would allow private dependencies to introduce qualified constraints on packages for packages in a specific private scope, and would ensure top-level constraints do not apply unnecessarily to private scopes.

cc @grayjay

@philderbeast
Copy link
Collaborator

philderbeast commented Mar 11, 2024

I was surprised by the many anys in the freeze file the first time I saw them. There's very little written about these qualifiers in the docs, just a small note and example;

    tools. To explicitly apply a constraint to a setup or build
    tool dependency, you can add a qualifier ``setup`` or ``any``
    to the constraint as follows:

    ::

        # Example use of the 'any' qualifier. This constraint
        # applies to package bar anywhere in the dependency graph.
        $ cabal install --constraint="any.bar == 1.0"

    ::

        # Example uses of 'setup' qualifiers.

        # This constraint applies to package bar when it is a
        # dependency of any Setup.hs script.
        $ cabal install --constraint="setup.bar == 1.0"

        # This constraint applies to package bar when it is a
        # dependency of the Setup.hs script of package foo.
        $ cabal install --constraint="foo:setup.bar == 1.0"

    ..  TODO: Uncomment this example once we decide on a syntax for 'exe'.
    ..  # Example use of the 'exe' (executable build tool)
        # qualifier. This constraint applies to package baz when it
        # is a dependency of the build tool bar being used to
        # build package foo.
        $ cabal install --constraint="foo:bar:exe.baz == 1.0"

@alt-romes alt-romes self-assigned this Mar 12, 2024
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 14, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 14, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 14, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 15, 2024
Qualifiers in the cabal freeze should definitely not always be "any".

(it can cause inconsistencies, such as
    `cabal freeze --constraint=... && cabal build`
being different from
    `cabal build --constraint=...`
)

In this commit we propagate information on the scopes in which each
package was solved to be able to generate a proper freeze file where
each package solved is constrained in the scope it was solved in.

Fixes haskell#9799
@alt-romes alt-romes linked a pull request Mar 15, 2024 that will close this issue
5 tasks
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 15, 2024
Qualifiers in the cabal freeze should definitely not always be "any".

(it can cause inconsistencies, such as
    `cabal freeze --constraint=... && cabal build`
being different from
    `cabal build --constraint=...`
)

In this commit we propagate information on the scopes in which each
package was solved to be able to generate a proper freeze file where
each package solved is constrained in the scope it was solved in.

Fixes haskell#9799
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 15, 2024
Qualifiers in the cabal freeze should definitely not always be "any".

(it can cause inconsistencies, such as
    `cabal freeze --constraint=... && cabal build`
being different from
    `cabal build --constraint=...`
)

In this commit we propagate information on the scopes in which each
package was solved to be able to generate a proper freeze file where
each package solved is constrained in the scope it was solved in.

Fixes haskell#9799
alt-romes added a commit to alt-romes/cabal that referenced this issue Mar 15, 2024
Qualifiers in the cabal freeze should definitely not always be "any".

(it can cause inconsistencies, such as
    `cabal freeze --constraint=... && cabal build`
being different from
    `cabal build --constraint=...`
)

In this commit we propagate information on the scopes in which each
package was solved to be able to generate a proper freeze file where
each package solved is constrained in the scope it was solved in.

Fixes haskell#9799
alt-romes added a commit to alt-romes/cabal that referenced this issue Apr 15, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
alt-romes added a commit to alt-romes/cabal that referenced this issue Apr 15, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
alt-romes added a commit to alt-romes/cabal that referenced this issue Apr 15, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
alt-romes added a commit to alt-romes/cabal that referenced this issue Apr 15, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
Mikolaj pushed a commit to alt-romes/cabal that referenced this issue Apr 17, 2024
Add tests for haskell#9799 about freeze qualifying all packages with 'any'
constraint scope.
mergify bot added a commit that referenced this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants