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

Can a dependency be a TARGET? #10695

Open
philderbeast opened this issue Jan 1, 2025 · 0 comments
Open

Can a dependency be a TARGET? #10695

philderbeast opened this issue Jan 1, 2025 · 0 comments

Comments

@philderbeast
Copy link
Collaborator

philderbeast commented Jan 1, 2025

This function shows every single single component in elaboratedPlanToExecute. This does not correspond to the list of available targets.

E.g.

✦ ~/code/cabal branchless/09946f1d1fa1217f4480d9ac919e2b264b5a3ecb*
λ $(cabal list-bin cabal) target
...
 - uuid-types:lib
 - vector-algorithms:lib
 - vector-binary-instances:lib
 - vector-stream:lib
 - vector-th-unbox:lib
 - vector:lib
 - wherefrom-compat:lib
 - witherable:lib
 - zinza:lib
 - zlib:lib

✦ ~/code/cabal branchless/09946f1d1fa1217f4480d9ac919e2b264b5a3ecb* 10s
λ $(cabal list-bin cabal) build zlib:lib
Warning: this is a debug build of cabal-install with assertions enabled.
Error: [Cabal-7130]
Internal error in target matching: could not make an unambiguous fully qualified target
selector for 'zlib:lib'. We made the target 'zlib:lib' (unknown-component) that was expected
to be unambiguous but matches the following targets:
'zlib:lib', matching:
  - zlib:lib (unknown-component)
  - :pkg:zlib:lib:zlib:file:lib (unknown-file)

Note: Cabal expects to be able to make a single fully qualified name for a target or provide
a more specific error. Our failure to do so is a bug in cabal.
Tracking issue: https://github.com/haskell/cabal/issues/8684

Hint: this may be caused by trying to build a package that exists in the project directory but
is missing from the 'packages' stanza in your cabal project file.

Originally posted by @andreabedini in #9744 (comment)

I added a printPlanTargetForms that would print zlib:lib as if it was a target. With the above command snippet, @andreabedini shows that this is not a target. I did a little more exploration around this and found that while zlib:lib and zlib:lib:zlib are rejected as targets (to the build command for example), the package name by itself is not rejected in the same way.

$ cabal clean

$ cabal build zlib:lib
...
Error: [Cabal-7130] (as above)
...

$ cabal build zlib:lib:zlib
...
Error: [Cabal-7130]
Internal error in target matching: could not make an unambiguous fully qualified target
selector for 'zlib:lib:zlib'. We made the target 'zlib:lib:zlib' (unknown-component) that was
expected to be unambiguous but matches the following targets:
'zlib:lib:zlib', matching:
  - zlib:lib:zlib (unknown-component)
  - zlib:lib:zlib (unknown-file)
':pkg:zlib:lib:zlib', matching:
  - zlib:lib:zlib (unknown-component)
...

$ cabal build zlib
...
Resolving dependencies...
Up to date

We can cabal build all --only-dependencies and this will:

Install only the dependencies necessary to build the given packages.

SOURCE: cabal users guide - phase control

If it is possible to build only dependencies then is it possible to build only a single dependency? If so, where do I go looking for the build artifacts?

What is cabal actually doing with cabal build zlib? Is zlib a target?

$ cabal build --help
Compile targets within the project.

Usage: cabal build [TARGETS] [FLAGS]
@philderbeast philderbeast changed the title When is a component a target? Can a dependency be a TARGET? Jan 1, 2025
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

1 participant