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 list-bin cabal-tests (and others) fails with "No or multiple targets given" #7679

Closed
fgaz opened this issue Sep 22, 2021 · 12 comments · Fixed by #7791
Closed

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

fgaz opened this issue Sep 22, 2021 · 12 comments · Fixed by #7791
Labels
attention: pr-welcome cabal-install: cmd/list-bin can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug

Comments

@fgaz
Copy link
Member

fgaz commented Sep 22, 2021

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

@fgaz fgaz added the type: bug label Sep 22, 2021
@fgaz fgaz changed the title cabal list-bin cabal-tests fails cabal list-bin cabal-tests fails with "No or multiple targets given" Sep 29, 2021
@fgaz fgaz 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" Sep 29, 2021
@fgaz
Copy link
Member Author

fgaz commented Sep 29, 2021

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

@fgaz fgaz added the can-workaround There is a (maybe partial) workaround for the issue or missing feature label Sep 29, 2021
@fgaz
Copy link
Member Author

fgaz commented Oct 10, 2021

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

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

@fgaz
Copy link
Member Author

fgaz commented Oct 10, 2021

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:

@jneira
Copy link
Member

jneira commented Oct 10, 2021

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

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

@mouse07410
Copy link
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 ;-)

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

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

@larskuhtz
Copy link
Collaborator

larskuhtz commented Nov 2, 2021

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

@larskuhtz
Copy link
Collaborator

cf. #7791 for a proposed fix

@larskuhtz
Copy link
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
Labels
attention: pr-welcome cabal-install: cmd/list-bin can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants