cabal icon indicating copy to clipboard operation
cabal copied to clipboard

plan.json includes internal libraries which aren't built.

Open phadej opened this issue 5 years ago • 2 comments

Describe the bug

plan.json includes also internal libraries which aren't always built.

To Reproduce

$ cabal v2-install --lib overloaded

In ~/.ghc/.../environments/default I get

package-id overloaded-0.1.3-0f5ef0185b0463d9c537b950ec837dc1f2c91bda0aab9c3e85c6116c29835dbf
package-id overloaded-0.1.3-cbb948b926e47cefb1f7cce1fac8681fbaa99202a33cb5a0225d7225620c3ed2

one of which is overloaded library, and the second is overloaded:optics-hasfield which is not what I asked for.


Similarly if I depend on overloaded in a package, the overloaded:optics-hasfield will pop into plan.json, even cabal v2-build doesn't build it.

Expected behavior

cabal should be more precise.

phadej avatar Dec 08 '19 22:12 phadej

Note: including internal package into environment exposes it modules. So this might cause unfortunate surprises!

~ % cabal v2-install --lib overloaded
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - overloaded-0.1.3 (lib:optics-hasfield) (requires build)
Starting     overloaded-0.1.3 (lib:optics-hasfield)
Building     overloaded-0.1.3 (lib:optics-hasfield)
Installing   overloaded-0.1.3 (lib:optics-hasfield)
Completed    overloaded-0.1.3 (lib:optics-hasfield)

~ % ghci
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/phadej/.ghc/x86_64-linux-8.6.5/environments/default
Prelude> :m +Optics.HasField
Prelude Optics.HasField>

Optics.HasField is a module of internal overloaded:optics-hasfield library. The above should not work.

phadej avatar Dec 08 '19 22:12 phadej

The unnecessary internal libraries in plan.json are probably caused by the dependency solver always solving for all components. #5413 and #5136 are also related.

grayjay avatar Dec 11 '19 06:12 grayjay