Skip to content

Project package with only a sublibrary does not work as a dependency #6896

@mpilgrem

Description

@mpilgrem

Stack 3.9.3 and a Stack project with two project packages myPackageA, myPackageB.

myPackageB provides only a sublibrary myPackageB-sub. myPackageA provides only an executable which depends on myPackageB:myPackageB-sub.

stack build fails with:

myPackageB> configure (sub-lib)
myPackageB> Configuring myPackageB-0.0.0...
myPackageB> build (sub-lib) with ghc-9.10.3
myPackageB> Preprocessing library 'myPackageB-sub' for myPackageB-0.0.0...
myPackageB> Building library 'myPackageB-sub' for myPackageB-0.0.0...
myPackageB> [1 of 1] Compiling Lib
myPackageB> copy/register
myPackageB> Installing internal library myPackageB-sub in D:\Users\mike\Code\Haskell\testSublibOnly\.stack-work\install\6e44f233\lib\x86_64-windows-ghc-9.10.3-b42a\myPackageB-0.0.0-HywWAukSPzk1yiyUrr6g43-myPackageB-sub
myPackageB> Registering library 'myPackageB-sub' for myPackageB-0.0.0...
myPackageA> configure (exe)
myPackageA> Configuring myPackageA-0.0.0...
myPackageA> Error: [Cabal-8010]
myPackageA> Encountered missing or private dependencies:
myPackageA>     myPackageB:myPackageB-sub
myPackageA>
Completed 2 action(s).

Error: [S-7282]
       Stack failed to execute the build plan.
       ...

However, if myPackageB is given an 'empty' main library:

# package.yaml for myPackageB (extract)

library: {}

stack build works, with:

myPackageB> configure (lib + sub-lib)
myPackageB> Configuring myPackageB-0.0.0...
myPackageB> build (lib + sub-lib) with ghc-9.10.3
myPackageB> Preprocessing library 'myPackageB-sub' for myPackageB-0.0.0...
myPackageB> Building library 'myPackageB-sub' for myPackageB-0.0.0...
myPackageB> [1 of 1] Compiling Lib
myPackageB> Preprocessing library for myPackageB-0.0.0...
myPackageB> Building library for myPackageB-0.0.0...
myPackageB> copy/register
myPackageB> Installing internal library myPackageB-sub in D:\Users\mike\Code\Haskell\testSublibOnly\.stack-work\install\6e44f233\lib\x86_64-windows-ghc-9.10.3-b42a\myPackageB-0.0.0-HywWAukSPzk1yiyUrr6g43-myPackageB-sub
myPackageB> Installing library in D:\Users\mike\Code\Haskell\testSublibOnly\.stack-work\install\6e44f233\lib\x86_64-windows-ghc-9.10.3-b42a\myPackageB-0.0.0-2qtKk7vPuVZ5DosdwyQR74
myPackageB> Registering library 'myPackageB-sub' for myPackageB-0.0.0...
myPackageB> Registering library for myPackageB-0.0.0...
myPackageA> configure (exe)
myPackageA> Configuring myPackageA-0.0.0...
myPackageA> build (exe) with ghc-9.10.3
myPackageA> Preprocessing executable 'myExe' for myPackageA-0.0.0...
myPackageA> Building executable 'myExe' for myPackageA-0.0.0...
myPackageA> [1 of 1] Compiling Main
myPackageA> [2 of 2] Linking .stack-work\dist\1a191874\build\myExe\myExe.exe
myPackageA> copy/register
myPackageA> Installing executable myExe in D:\Users\mike\Code\Haskell\testSublibOnly\.stack-work\install\6e44f233\bin
Completed 2 action(s).

Is this a Stack bug?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions