Skip to content

Have cabal target show the impossible #10766

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

Open
philderbeast opened this issue Jan 22, 2025 · 4 comments
Open

Have cabal target show the impossible #10766

philderbeast opened this issue Jan 22, 2025 · 4 comments
Labels
re: target Concerning build targets like pkg:lib type: bug

Comments

@philderbeast
Copy link
Collaborator

Describe the bug
If the build plan does not exist then the targets that do exist but are impossible to build are not shown with cabal target.

To Reproduce
With the following .cabal file that is buildable, the one test suite is shown as a target.

$ cat build-tool-depends-twice.cabal 
cabal-version:      3.0
name:               build-tool-depends-twice
version:            0.1.0.0
build-type:         Simple

common warnings
    ghc-options: -Wall

test-suite build-tool-depends-twice-test
    import:           warnings
    default-language: Haskell2010
    type:             exitcode-stdio-1.0
    hs-source-dirs:   test
    main-is:          Main.hs
    build-depends:    base >=4 && <5
    build-tool-depends: markdown-unlit:markdown-unlit > 0.5.0 && <= 0.6

$ cabal target all:tests
...
Fully qualified target forms:
 - build-tool-depends-twice:test:build-tool-depends-twice-test
Found 1 target matching all:tests.

If I now alter the package, adding an impossible to satisfy constraint then the target is not shown.

     build-tool-depends: markdown-unlit:markdown-unlit > 0.5.0 && <= 0.6
+    build-tool-depends: markdown-unlit:markdown-unlit <0
$ cabal target all:tests
...
Error: [Cabal-7127]
Cannot target all the test suites in the project because none of the components
are available to build: the test suite 'build-tool-depends-twice-test' is not
available because the solver picked a plan that does not include the test
suites, perhaps because no such plan exists. To see the error message explaining
the problems with such plans, force the solver to include the test suites for
all packages, by adding the line 'tests: True' to the 'cabal.project.local'
file.

Expected behavior
If the target exists in the package, buildable or not, then show it as a target, maybe annotating or separately listing unbuildable ones. This would include buildable: False ones too.

@philderbeast
Copy link
Collaborator Author

If I "force the solver" as suggested, the target is still not shown. We see the solver error message:

$ cabal target all:tests --enable-tests
...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: build-tool-depends-twice-0.1.0.0 (user goal)
[__1] trying: build-tool-depends-twice:*test
[__2] next goal: build-tool-depends-twice:markdown-unlit:exe.markdown-unlit (dependency of build-tool-depends-twice *test)
[__2] rejecting: build-tool-depends-twice:markdown-unlit:exe.markdown-unlit; 0.6.0, 0.5.1, 0.5.0, 0.4.1, 0.4.0, 0.3.1, 0.2.0.1, 0.2.0, 0.1.0, 0.3.0 (conflict: build-tool-depends-twice *test => build-tool-depends-twice:markdown-unlit:exe.markdown-unlit (exe markdown-unlit)<0 && >0.5.0 && <=0.6)
[__2] fail (backjumping, conflict set: build-tool-depends-twice, build-tool-depends-twice:markdown-unlit:exe.markdown-unlit, build-tool-depends-twice:test)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: build-tool-depends-twice, build-tool-depends-twice:test, build-tool-depends-twice:markdown-unlit:exe.markdown-unlit

@philderbeast
Copy link
Collaborator Author

philderbeast commented Jan 22, 2025

I would have thought all:tests implied --enable-tests. Without the impossible to satisfy <0 constraint it seems to.

  • all doesn't enable tests.
$ cabal target all
Warning: this is a debug build of cabal-install with assertions enabled.
Resolving dependencies...
Error: [Cabal-7127]
Cannot target all the packages in the project because none of the components are available to build:
the test suite 'build-tool-depends-twice-test' will not be built because test suites are not built by default
in the current configuration (but you can still build them specifically)
  • all --enable-tests enables tests.
$ cabal target all --enable-tests
...
Fully qualified target forms:
 - build-tool-depends-twice:test:build-tool-depends-twice-test
Found 1 target matching all.
  • all:tests seems to enable tests too, doesn't it?
$ cabal target all:tests
...
Fully qualified target forms:
 - build-tool-depends-twice:test:build-tool-depends-twice-test
Found 1 target matching all:tests.
  • all:tests --disable-tests does what I'd expect with --disable-tests overriding the enabling of all:tests.
$ cabal target all:tests --disable-tests
...
Error: [Cabal-7127]
Cannot target all the test suites in the project because none of the components are available to build:
the test suite 'build-tool-depends-twice-test' is  not available because building test suites has been
disabled in the configuration

Also cabal build all:tests builds the test suite whereas cabal build all doesn't.

@ffaf1
Copy link
Collaborator

ffaf1 commented Jan 23, 2025

This would include buildable: False ones too.

Mhhh not a big fan (depending on the UI), imagine for packages with many examples like SDL.
On the other side, for sure it is useful in some cases.

@ffaf1 ffaf1 added re: target Concerning build targets like pkg:lib and removed needs triage labels Jan 23, 2025
@grayjay
Copy link
Collaborator

grayjay commented Jan 23, 2025

This issue looks like it is related to #7883. The problem is that the solver currently only enables tests with a preference, not a hard constraint, unless --enable-tests is given. I think that the proposed solution was to change the default to enable tests with a hard constraint. Then tests could be disabled with --disable-tests when necessary. It would remove a lot of the confusion around tests not being available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: target Concerning build targets like pkg:lib type: bug
Projects
None yet
Development

No branches or pull requests

3 participants