Skip to content

cabal list-bin cabal-tests (and others) fails with "No or multiple targets given" #7679

Closed

Description

@fgaz

Describe the bug

cabal list-bin cabal-tests complains about zero or multiple targets, even when a qualified target is used. I'm not sure why the error happens only with cabal-tests

To Reproduce

> cabal list-bin cabal-testsuite:exe:cabal-tests
cabal: No or multiple targets given

Expected behavior

  • getting the path to cabal-tests
  • a better error

System information

Additional context

#7648 (comment)

Workaround

use cabal-plan list-bin

Activity

  1. changed the title [-]cabal list-bin cabal-tests fails[/-] [+]cabal list-bin cabal-tests fails with "No or multiple targets given"[/+] on Sep 29, 2021
  2. changed the title [-]cabal list-bin cabal-tests fails with "No or multiple targets given"[/-] [+]cabal list-bin cabal-tests (and others) fails with "No or multiple targets given"[/+] on Sep 29, 2021
  3. fgaz commented on Sep 29, 2021

    @fgaz
    MemberAuthor

    It looks like this happened in the wild agda/agda#4216 (comment)

  4. added
    can-workaround
    on Sep 29, 2021
  5. fgaz commented on Oct 10, 2021

    @fgaz
    MemberAuthor

    @mouse07410 in #7739 you explicitly mentioned cabal 3.6 in the title. Is this a regression from 3.4 or earlier?

  6. mouse07410 commented on Oct 10, 2021

    @mouse07410
    Collaborator

    I mentioned 3.6.0.0 because that's what I'm using, and thought you need to know.

    Unfortunately, I don't even have cabal-3.4.0.0 anymore. Are you saying that fur debugging you'd like me to install 3.4.0.0 again and try cabal list-bins?

    Since I never tried this command (list-bins) in the past, and only trying it now to avoid the rebuild caused by install, there's a good reason to assume this but was present in older versions as well.

  7. fgaz commented on Oct 10, 2021

    @fgaz
    MemberAuthor

    Are you saying that fur debugging you'd like me to install 3.4.0.0 again and try cabal list-bins?

    No need. I just wanted to confirm you weren't implying this is a regression (from what I remember it isn't, it's always been like this).

    Also, you mentioned a workaround - using cabal-plan. Unfortunately, one cannot build it with current GHC-9.0.1

    relevant cabal-plan ticket:

  8. jneira commented on Oct 10, 2021

    @jneira
    Member

    strange, I was able to install cabal-plan executable in the past, maybe some project config is interfering with? could you try to execute the command outside of any project (so out of any subdir of a project too)? will try to reproduce asap

  9. mouse07410 commented on Oct 10, 2021

    @mouse07410
    Collaborator

    strange, I was able to install cabal-plan executable in the past, maybe some project config is interfering with? could you try to execute the command outside of any project (so out of any subdir of a project too)? will try to reproduce asap

    No need to. A couple-of-days-old cabal installed cabal-plan 0.7.2.0 as a library only. After cabal update, it installed 0.7.2.1 with the necessary executable. So, cabal-plan utility is installed and running.

    Problem - it's of limited usefulness fur dynamic executables.

  10. mouse07410 commented on Oct 10, 2021

    @mouse07410
    Collaborator

    attention: pr-welcome

    If I could - I would. Sorry, beyond my competence. E.g., I can tell a good painting from a bad one, but I can't re-create a good one ;-)

  11. larskuhtz commented on Nov 2, 2021

    @larskuhtz
    Collaborator

    Not sure if it is related: After adding a test suite to a package, cabal list-bin stopped working with cabal: No or multiple targets given. The test suite is called tests, which is different from the name of the executable.

    I tried all kinds of syntax for qualifying the target (as described in the latest docs), but none worked and some resulted in confusing failure messages, that indicate that more might be wrong with list-bin.

  12. larskuhtz commented on Nov 2, 2021

    @larskuhtz
    Collaborator

    I made the failure message a bit more verbose and it turns out that the problem is that cabal list-bin PROGRAM_NAME fails be finding two targets: the executable (PROGRAM_NAME) and the test suite which is called tests. The same result is returns with cabal list-bin executable:PROGRAM_NAME.

    So, problem (at least in my case) seems to be that cabal includes the test suite in the result, even though it is clearly not specified as a target.

  13. larskuhtz commented on Nov 2, 2021

    @larskuhtz
    Collaborator

    Some more details. Here is an example run that logs the targetSelector as well as the final (reject) list of targets.

    Note how the qualified target selector explicitly selects: the package (chainweb-mining-client), the kind (CEceName), and the component name (chainweb-mining-client), yet list of selected targets include the test-suite (build/tests/tests).

    $ cabal list-bin --disable-tests chainweb-mining-client:executable:chainweb-mining-client
    "targetSelectors: [TargetComponent (PackageIdentifier {pkgName = PackageName \"chainweb-mining-client\", pkgVersion = mkVersion [0,2]}) (CExeName (UnqualComponentName \"chainweb-mining-client\")) WholeComponent]"
    Error: cabal: Multiple targets found:
    ["/Users/lars/Code/chainweb/chainweb-mining-client/dist-newstyle/build/x86_64-osx/ghc-9.0.1/chainweb-mining-client-0.2/build/chainweb-mining-client/chainweb-mining-client","/Users/lars/Code/chainweb/chainweb-mining-client/dist-newstyle/build/x86_64-osx/ghc-9.0.1/chainweb-mining-client-0.2/build/tests/tests"]
    
  14. larskuhtz commented on Nov 2, 2021

    @larskuhtz
    Collaborator

    cf. #7791 for a proposed fix

  15. larskuhtz commented on Nov 2, 2021

    @larskuhtz
    Collaborator

    #7791 resolves the original issue that is described above:

    > cabal list-bin cabal-testsuite:exe:cabal-tests
    cabal: No or multiple targets given
    
    > $(cabal list-bin cabal-install:cabal) list-bin cabal-testsuite:exe:cabal-tests
    /Users/lars/Code/github/cabal/dist-newstyle/build/x86_64-osx/ghc-9.0.1/cabal-testsuite-3/build/cabal-tests/cabal-tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    attention: pr-welcomecabal-install: cmd/list-bincan-workaroundtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions