Can a dependency be a TARGET?
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
> 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 https://github.com/haskell/cabal/pull/9744#discussion_r1655811109_
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](https://cabal.readthedocs.io/en/latest/cabal-project-description-file.html#cmdoption-only-dependencies)
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]
```
Contributor guide
Assessment
This issue has not been assessed yet.