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

internal error: could not construct a valid install plan #4980

Open
hvr opened this issue Dec 27, 2017 · 4 comments
Open

internal error: could not construct a valid install plan #4980

hvr opened this issue Dec 27, 2017 · 4 comments

Comments

@hvr
Copy link
Member

hvr commented Dec 27, 2017

This could be a duplicate of another bug, but I'm not sure; I'm recording this here in case it isn't:

Given the following simple cabal file

name:                cabal-bug
version:             0
cabal-version:       2.0
build-type: Simple

library
  build-depends:       text == 1.2.3.0, binary == 0.4

cabal runs into an internal error:

$ cabal new-build -w ghc-7.0.4 --dry -vnormal+nowrap -v3

...

Resolving dependencies...
targets: cabal-bug
constraints: 
  any.base installed (non-upgradeable package)
  any.ghc-prim installed (non-upgradeable package)
  any.integer-gmp installed (non-upgradeable package)
  any.template-haskell installed (non-upgradeable package)
  setup.Cabal >=1.20 (minimum version of Cabal used by Setup.hs)
  cabal-bug.cabal-bug ==0 (user target)
preferences: 

...

strategy: PreferLatestForSelected
reorder goals: False
count conflicts: True
independent goals: False
avoid reinstalls: False
shadow packages: False
strong flags: False
allow boot library installs: False
max backjumps: 2000
[__0] trying: cabal-bug-0 (user goal)
[__1] next goal: binary (dependency of cabal-bug)
[__1] rejecting: binary-0.8.5.1, binary-0.8.5.0, binary-0.8.4.1, binary-0.8.4.0, binary-0.8.3.0, binary-0.8.2.1, binary-0.8.2.0, binary-0.8.1.0, binary-0.8.0.1, binary-0.8.0.0, binary-0.7.6.1, binary-0.7.6.0, binary-0.7.5.0, binary-0.7.4.0, binary-0.7.3.0, binary-0.7.2.3, binary-0.7.2.2, binary-0.7.2.1, binary-0.7.2.0, binary-0.7.1.0, binary-0.7.0.1, binary-0.7.0.0, binary-0.6.4.0, binary-0.6.3.0, binary-0.6.2.0, binary-0.6.1.0, binary-0.6.0.0, binary-0.5.1.1, binary-0.5.1.0, binary-0.5.0.2, binary-0.5.0.1, binary-0.5, binary-0.4.5, binary-0.4.4, binary-0.4.3.1, binary-0.4.3, binary-0.4.2, binary-0.4.1 (conflict: cabal-bug => binary==0.4)
[__1] trying: binary-0.4
[__2] trying: base-4.3.1.0/installed-baf... (dependency of binary)
[__3] trying: binary:setup.base~>base-4.3.1.0/installed-baf... (dependency of binary)
[__4] trying: rts-1.0/installedbuil... (dependency of base)
[__5] trying: ffi-1.0/installedbuil... (dependency of rts)
[__6] trying: integer-gmp-0.2.0.3/installed-298... (dependency of base)
[__7] trying: ghc-prim-0.2.0.0/installed-d9d... (dependency of base)
[__8] trying: bytestring-0.9.1.10/installed-6aa... (dependency of binary)
[__9] trying: array-0.3.0.2/installed-143... (dependency of binary)
[_10] trying: containers-0.4.0.0/installed-b48... (dependency of binary)
[_11] trying: text-1.2.3.0 (dependency of cabal-bug)
[_12] trying: text:!test
[_13] next goal: deepseq (dependency of text)
[_13] rejecting: deepseq-1.4.3.0 (conflict: base==4.3.1.0/installed-baf..., deepseq => base>=4.5 && <4.11)
[_13] trying: deepseq-1.4.2.0
[_14] trying: deepseq:!test
[_15] trying: text:-integer-simple
[_16] trying: text:-developer
[_17] rejecting: text:-bytestring-builder (conflict: bytestring==0.9.1.10/installed-6aa..., text -bytestring-builder => bytestring>=0.10.4)
[_17] trying: text:+bytestring-builder
[_18] trying: bytestring-builder-0.10.8.1.0 (dependency of text +bytestring-builder)
[_19] rejecting: bytestring-builder:+bytestring_has_builder (conflict: bytestring==0.9.1.10/installed-6aa..., bytestring-builder +bytestring_has_builder => bytestring>=0.10.4)
[_19] trying: bytestring-builder:-bytestring_has_builder
[_20] trying: binary:setup.rts~>rts-1.0/installedbuil... (dependency of binary:setup.base)
[_21] trying: binary:setup.ffi~>ffi-1.0/installedbuil... (dependency of binary:setup.rts)
[_22] trying: binary:setup.integer-gmp~>integer-gmp-0.2.0.3/installed-298... (dependency of binary:setup.base)
[_23] next goal: binary:setup.Cabal (dependency of binary)
[_23] rejecting: binary:setup.Cabal-1.10.2.0/installed-9af... (constraint from minimum version of Cabal used by Setup.hs requires >=1.20)
[_23] rejecting: binary:setup.Cabal-2.0.1.1, binary:setup.Cabal-2.0.1.0, binary:setup.Cabal-2.0.0.2 (conflict: binary => binary:setup.Cabal>=0 && <1.25)
[_23] rejecting: binary:setup.Cabal-1.24.2.0, binary:setup.Cabal-1.24.0.0 (conflict: binary:setup.base==4.3.1.0/installed-baf..., binary:setup.Cabal => binary:setup.base>=4.5 && <5)
[_23] rejecting: binary:setup.Cabal-1.22.8.0, binary:setup.Cabal-1.22.7.0, binary:setup.Cabal-1.22.6.0, binary:setup.Cabal-1.22.5.0, binary:setup.Cabal-1.22.4.0, binary:setup.Cabal-1.22.3.0, binary:setup.Cabal-1.22.2.0, binary:setup.Cabal-1.22.1.1, binary:setup.Cabal-1.22.1.0, binary:setup.Cabal-1.22.0.0 (conflict: binary:setup.base==4.3.1.0/installed-baf..., binary:setup.Cabal => binary:setup.base>=4.4 && <5)
[_23] trying: binary:setup.Cabal-1.20.0.4
[_24] trying: binary:setup.Cabal:!test
[_25] trying: binary:setup.template-haskell-2.5.0.0/installed-957... (dependency of binary)
[_26] trying: binary:setup.ghc-prim~>ghc-prim-0.2.0.0/installed-d9d... (dependency of binary)
[_27] trying: binary:setup.unix-2.4.2.0/installed-764... (dependency of binary)
[_28] trying: binary:setup.transformers-0.5.5.0 (dependency of binary)
[_29] trying: binary:setup.time-1.2.0.3/installed-349... (dependency of binary)
[_30] trying: binary:setup.old-locale-1.0.0.2/installed-161... (dependency of binary:setup.time)
[_31] trying: binary:setup.process-1.0.1.5/installed-da4... (dependency of binary)
[_32] trying: binary:setup.pretty-1.0.1.2/installed-f8d... (dependency of binary)
[_33] trying: binary:setup.old-time-1.0.0.6/installed-7f1... (dependency of binary)
[_34] trying: binary:setup.filepath-1.2.0.0/installed-b4f... (dependency of binary)
[_35] trying: binary:setup.directory-1.1.0.0/installed-393... (dependency of binary)
[_36] next goal: binary:setup.deepseq (dependency of binary)
[_36] rejecting: binary:setup.deepseq~>deepseq-1.4.2.0, binary:setup.deepseq-1.4.3.0 (conflict: binary:setup.Cabal => binary:setup.deepseq>=1.3 && <1.4)
[_36] rejecting: binary:setup.deepseq-1.4.2.0 (multiple instances)
[_36] rejecting: binary:setup.deepseq-1.4.1.2, binary:setup.deepseq-1.4.1.1, binary:setup.deepseq-1.4.1.0, binary:setup.deepseq-1.4.0.0 (conflict: binary:setup.Cabal => binary:setup.deepseq>=1.3 && <1.4)
[_36] trying: binary:setup.deepseq-1.3.0.2
[_37] trying: binary:setup.containers~>containers-0.4.0.0/installed-b48... (dependency of binary)
[_38] trying: binary:setup.bytestring~>bytestring-0.9.1.10/installed-6aa... (dependency of binary)
[_39] trying: binary:setup.binary~>binary-0.4 (dependency of binary)
[_40] next goal: binary:setup.array (dependency of binary)
[_40] trying: binary:setup.array~>array-0.3.0.2/installed-143...
[_41] done
internal error: could not construct a valid install plan.
The proposed (invalid) plan contained the following problems:
Package binary-0.4 has an invalid configuration, in particular:
  the package has a dependency binary -any but no package has been selected to satisfy it.

Proposed plan:
PreExisting ffi-1.0 (builtin_ffi)
PreExisting rts-1.0 (builtin_rts)
PreExisting ghc-prim-0.2.0.0 (ghc-prim-0.2.0.0-d9df11f804556f362beb0ea4e67261ba)
PreExisting integer-gmp-0.2.0.3 (integer-gmp-0.2.0.3-298c59ba68b7aaa7e76ae5b1fe5e876e)
PreExisting base-4.3.1.0 (base-4.3.1.0-bafbc7ad22c91044397c91929f8c61bc)
PreExisting unix-2.4.2.0 (unix-2.4.2.0-7643ffafb38b84c18b4316347085103e)
Configured transformers-0.5.5.0
PreExisting old-locale-1.0.0.2 (old-locale-1.0.0.2-161f79060c89cc16ca11576ceb440486)
PreExisting time-1.2.0.3 (time-1.2.0.3-3493203919ef238f1a58223fa55b1ceb)
PreExisting pretty-1.0.1.2 (pretty-1.0.1.2-f8dc299a95cc94a3e513e27c5b80f951)
PreExisting old-time-1.0.0.6 (old-time-1.0.0.6-7f15fd4b960098b2776b8c05bc17519f)
PreExisting filepath-1.2.0.0 (filepath-1.2.0.0-b4f4cf7e95546b00f075372f0ccb0653)
PreExisting directory-1.1.0.0 (directory-1.1.0.0-393d8e95f1c0dd6ee908e122f924ac85)
PreExisting process-1.0.1.5 (process-1.0.1.5-da4848a2eec47420cd09fe9edba7e83c)
PreExisting bytestring-0.9.1.10 (bytestring-0.9.1.10-6aa1efbfa95d1689fc03d61e7c4b27c4)
PreExisting array-0.3.0.2 (array-0.3.0.2-143060371bda4ff52c270d1067551fe8)
Configured deepseq-1.3.0.2
PreExisting containers-0.4.0.0 (containers-0.4.0.0-b4885363abca642443ccd842502a3b7e)
PreExisting template-haskell-2.5.0.0 (template-haskell-2.5.0.0-957162165c2e6480a35f6d14f7e5220f)
Configured Cabal-1.20.0.4
Configured binary-0.4
Configured deepseq-1.4.2.0
Configured bytestring-builder-0.10.8.1.0
Configured text-1.2.3.0
Configured cabal-bug-0

CallStack (from HasCallStack):
  error, called at ./Distribution/Client/Dependency.hs:807:33 in main:Distribution.Client.Dependency

/cc @grayjay

@hvr
Copy link
Member Author

hvr commented Dec 27, 2017

I guess the key information is

[_39] trying: binary:setup.binary~>binary-0.4 (dependency of binary)

IOW, the (ancient) package binary-0.4 is build-type: Custom, and has no custom-setup section (and we can't add one either, as the .cabal format is too ancient); and now the implicit setup-depends kicks in, which includes depending on binary.

I'm not sure if it's ever a good idea for setup-depends (even though being a qualified goal) to depend on a (different) version of the current package.

What if we filtered out the current package name from the implicit setup-depends?

@23Skidoo
Copy link
Member

What if we filtered out the current package name from the implicit setup-depends?

Sounds like a good idea.

@grayjay
Copy link
Collaborator

grayjay commented Dec 31, 2017

It looks like the solver failed to detect the cycle because of #4161 (It currently only checks for cycles between multiple packages). If it had detected the cycle, it could have tried the installed version of binary instead. I think there are some cases where packages use their installed versions in their setup scripts, at least indirectly through a dependency on Cabal, so I think we need to support that type of self-dependency. There was some discussion of this issue in #4154 (comment).

grayjay added a commit to grayjay/cabal that referenced this issue Jan 13, 2018
…askell#4161).

The solver already detected cycles involving more than one package, but it
allowed dependencies between components within a package.  This commit treats a
dependency between a package's setup script and library as a cycle in order to
allow the solver to backtrack and try to break the cycle.  A more thorough
solution would involve tracking all dependencies between components, as in

This commit also fixes the internal error in issue haskell#4980.
grayjay added a commit to grayjay/cabal that referenced this issue Jan 13, 2018
…askell#4161).

The solver already detected cycles involving more than one package, but it
allowed dependencies between components within a package.  This commit treats a
dependency between a package's setup script and library as a cycle in order to
allow the solver to backtrack and try to break the cycle.  A more thorough
solution would involve tracking all dependencies between components, as in haskell#4087.

This commit also fixes the internal error in issue haskell#4980.
grayjay added a commit to grayjay/cabal that referenced this issue Jan 17, 2018
…askell#4161).

The solver already detected cycles involving more than one package, but it
allowed dependencies between components within a package.  This commit treats a
dependency between a package's setup script and library as a cycle in order to
allow the solver to backtrack and try to break the cycle.  A more thorough
solution would involve tracking all dependencies between components, as in haskell#4087.

This commit also fixes the internal error in issue haskell#4980.
@grayjay
Copy link
Collaborator

grayjay commented Jan 21, 2018

#5023 fixed the internal error, but we should probably also filter the implicit setup-depends, and possibly prevent packages from directly depending on different versions of the same package in the solver (See #5023 (comment)).

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

3 participants