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

manual cabal flag toggled by modular solver #2280

Closed
hvr opened this issue Dec 17, 2014 · 13 comments
Closed

manual cabal flag toggled by modular solver #2280

hvr opened this issue Dec 17, 2014 · 13 comments

Comments

@hvr
Copy link
Member

hvr commented Dec 17, 2014

With GHC 7.9/7.10, only deepseq>=1.4.0.0 is installable.

semigroups-0.16 has the following flag defined:

flag deepseq
  description:
    You can disable the use of the `deepseq` package using `-f-deepseq`.
    .
    Disabing this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.
  default: True
  manual: True

and it's used for toggling a build-dep:

  if flag(deepseq)
    build-depends: deepseq >= 1.1 && < 1.4

So it's expected that semigroups-0.16 isn't installable with GHC 7.9/7.10. However, Cabal decides to toggle the deepseq flag, even though it isn't allowed to:

$ cabal install semigroups-0.16 -v2
Reading available packages...
Choosing modular solver.
Resolving dependencies...
Ready to install semigroups-0.16
Waiting for install task to finish...
Extracting
/home/hvr/.cabal/packages/hackage.haskell.org/semigroups/0.16/semigroups-0.16.tar.gz
to /tmp/semigroups-0.16-25781...
Updating semigroups.cabal with the latest revision from the index.
Configuring semigroups-0.16...
Flags chosen: unordered-containers=True, text=True, deepseq=False,
containers=True, bytestring=True, hashable=True
Dependency base ==4.8.0.0: using base-4.8.0.0
Dependency bytestring ==0.10.5.0: using bytestring-0.10.5.0
Dependency containers ==0.5.6.1: using containers-0.5.6.1
Dependency hashable ==1.2.3.0: using hashable-1.2.3.0
Dependency nats ==1: using nats-1
Dependency text ==1.2.0.3: using text-1.2.0.3
Dependency unordered-containers ==0.2.5.1: using unordered-containers-0.2.5.1
Using Cabal-1.21.1.0 compiled by ghc-7.4
Using compiler: ghc-7.9.20141216
Using install prefix: /home/hvr/.cabal
Binaries installed in: /home/hvr/.cabal/bin
Libraries installed in:
...

as you can see in the logging output above, surprisingly deepseq=False is set.

@23Skidoo
Copy link
Member

/cc @kosmikus

@hvr
Copy link
Member Author

hvr commented Dec 17, 2014

Here's some interesting output from -v3

strategy: PreferLatestForSelected
[__0] trying: semigroups-0.16 (user goal)
[__1] trying: base-4.8.0.0/installed-1d8... (dependency of semigroups-0.16)
[__2] trying: integer-gmp-1.0.0.0/installed-d89... (dependency of base-4.8.0.0/installed-1d8...)
[__3] trying: ghc-prim-0.3.1.0/installed-86d... (dependency of base-4.8.0.0/installed-1d8...)
[__4] trying: rts-1.0/installedbuil... (dependency of base-4.8.0.0/installed-1d8...)
[__5] trying: semigroups-0.16:+hashable
[__6] trying: semigroups-0.16:+unordered-containers
[__7] trying: unordered-containers-0.2.5.1/installed-09a... (dependency of semigroups-0.16:+unordered-containers)
[__8] trying: hashable-1.2.3.0/installed-52e... (dependency of unordered-containers-0.2.5.1/installed-09a...)
[__9] trying: text-1.2.0.3/installed-a66... (dependency of hashable-1.2.3.0/installed-52e...)
[_10] trying: array-0.5.0.1/installed-cb9... (dependency of text-1.2.0.3/installed-a66...)
[_11] trying: bytestring-0.10.5.0/installed-2ae... (dependency of hashable-1.2.3.0/installed-52e...)
[_12] trying: deepseq-1.4.0.0/installed-17a... (dependency of unordered-containers-0.2.5.1/installed-09a...)
[_13] trying: semigroups-0.16:+text
[_14] rejecting: semigroups-0.16:+deepseq (conflict: unordered-containers => deepseq==1.4.0.0/installed-17a..., semigroups-0.16:deepseq => deepseq>=1.1 && <1.4)
[_14] trying: semigroups-0.16:-deepseq
[_15] trying: semigroups-0.16:+containers
[_16] trying: containers-0.5.6.1/installed-54f... (dependency of semigroups-0.16:+containers)
[_17] trying: semigroups-0.16:+bytestring
[_18] trying: nats-1/installed-107... (dependency of semigroups-0.16)
[_19] done

@hvr hvr changed the title manual cabal flag toggled by solver manual cabal flag toggled by modular solver Dec 18, 2014
@hvr
Copy link
Member Author

hvr commented Dec 18, 2014

I just noticed that the topdownsolver correctly handles manual flags in this case, so this seems like an issue w/ the modular solver only.

Also, this bug occurs in cabal-1.18 and cabal-1.20 as well, but not in cabal-1.16; here's what cabal-1.16 says:

$ cabal-1.16 configure -v3
Warning: /home/hvr/.cabal/config: Unrecognized stanza on line 143
/home/hvr/.cabal/config: Unrecognized stanza on line 117
/home/hvr/.cabal/config: Unrecognized stanza on line 76
/home/hvr/.cabal/config: Unrecognized field extra-prog-path on line 43
searching for ghc in path.
found ghc at /opt/ghc/head/bin/ghc
("/opt/ghc/head/bin/ghc",["--numeric-version"])
/opt/ghc/head/bin/ghc is version 7.9.20141217
looking for tool "ghc-pkg" near compiler in /opt/ghc/head/bin
found ghc-pkg in /opt/ghc/head/bin/ghc-pkg
("/opt/ghc/head/bin/ghc-pkg",["--version"])
/opt/ghc/head/bin/ghc-pkg is version 7.9.20141217
("/opt/ghc/head/bin/ghc",["--supported-languages"])
("/opt/ghc/head/bin/ghc",["--info"])
Reading installed packages...
("/opt/ghc/head/bin/ghc-pkg",["dump","--global","-v0"])
("/opt/ghc/head/bin/ghc-pkg",["dump","--user","-v0"])
("/opt/ghc/head/bin/ghc",["--print-libdir"])
Reading available packages...
Choosing modular solver.
Resolving dependencies...
[__0] trying: semigroups-0.16
[__1] trying: base-4.8.0.0/installed-1db...
[__2] trying: integer-gmp-1.0.0.0/installed-921...
[__3] trying: ghc-prim-0.3.1.0/installed-449...
[__4] trying: rts-1.0/installedbuil...
[__5] trying: semigroups-0.16:+unordered-containers
[__6] trying: semigroups-0.16:+text
[__7] trying: semigroups-0.16:+hashable
[__8] trying: semigroups-0.16:+deepseq
[__9] trying: semigroups-0.16:+containers
[_10] trying: semigroups-0.16:+bytestring
[_11] rejecting: unordered-containers-0.2.5.1/installed-11a... (conflict:
unordered-containers => deepseq==1.4.0.0/installed-805...,
semigroups-0.16:deepseq => deepseq>=1.1 && <1.4)
[__9] fail (backjumping, conflict set: semigroups, unordered-containers,
semigroups-0.16:deepseq, semigroups-0.16:hashable,
semigroups-0.16:unordered-containers)
[__8] rejecting: semigroups-0.16:-deepseq (manual flag can only be changed
explicitly)
[__8] fail (backjumping, conflict set: semigroups, unordered-containers,
semigroups-0.16:deepseq, semigroups-0.16:hashable,
semigroups-0.16:unordered-containers)
[__7] rejecting: semigroups-0.16:-hashable (manual flag can only be changed
explicitly)
[__6] fail (backjumping, conflict set: semigroups, unordered-containers,
semigroups-0.16:deepseq, semigroups-0.16:hashable,
semigroups-0.16:unordered-containers)
[__5] rejecting: semigroups-0.16:-unordered-containers (manual flag can only
be changed explicitly)
[__0] fail (backjumping, conflict set: semigroups, unordered-containers,
semigroups-0.16:deepseq, semigroups-0.16:hashable,
semigroups-0.16:unordered-containers)
Could not resolve dependencies:
trying: semigroups-0.16
trying: semigroups-0.16:+unordered-containers
trying: semigroups-0.16:+hashable
trying: semigroups-0.16:+deepseq
rejecting: unordered-containers-0.2.5.1/installed-11a... (conflict:
unordered-containers => deepseq==1.4.0.0/installed-805...,
semigroups-0.16:deepseq => deepseq>=1.1 && <1.4)
Using internal setup method with build-type Simple and args:
["configure","--verbose=3","--ghc","--prefix=/home/hvr/.cabal","--user"]
Configuring semigroups-0.16...
creating dist
searching for ghc in path.
found ghc at /opt/ghc/head/bin/ghc
("/opt/ghc/head/bin/ghc",["--numeric-version"])
/opt/ghc/head/bin/ghc is version 7.9.20141217
looking for tool "ghc-pkg" near compiler in /opt/ghc/head/bin
found ghc-pkg in /opt/ghc/head/bin/ghc-pkg
("/opt/ghc/head/bin/ghc-pkg",["--version"])
/opt/ghc/head/bin/ghc-pkg is version 7.9.20141217
("/opt/ghc/head/bin/ghc",["--supported-languages"])
("/opt/ghc/head/bin/ghc",["--info"])
Reading installed packages...
("/opt/ghc/head/bin/ghc-pkg",["dump","--global","-v0"])
("/opt/ghc/head/bin/ghc-pkg",["dump","--user","-v0"])
("/opt/ghc/head/bin/ghc",["--print-libdir"])
cabal-1.16: At least the following dependencies are missing:
deepseq >=1.1 && <1.4

@kosmikus
Copy link
Contributor

Ok, I think I can reproduce this.

@kosmikus
Copy link
Contributor

I think I found the bug. So when fixing manual flags, the modular solver commits to the first still enabled choice at the time. The problem here is that at the point manual flags are enforced, the +deepseq choice has already been disabled. Working on a fix.

kosmikus added a commit that referenced this issue Dec 18, 2014
This hopefully addresses issue #2280.

The problem was as follows: In the modular solver, manual flags are
enforced. However, in order to respect manual choices by the user,
which are still allowed, we would first check if one of the two choices
had already been disabled, and only if that's not the case, disable
the non-default choice.

However, a manual user constraint is not the only reason why the default
flag choice can be disabled at this point. It can already be disabled
in the validation phase, if it's immediately obvious to the solver at
this point that it can never work. In such a situation (which is
described in #2280), the solver would then fail to respect a manual
flag and allow to change it without user intervention.

The fix seems simple: we now explicitly check whether the flag choice
has been disabled *by the user*, and only then leave it alone.
Otherwise, we enforce the manual flag.
@kosmikus
Copy link
Contributor

This should now be fixed in master. I cannot currently judge how much of a problem this error will be for users of old cabal versions that have the bug once the new GHC is released. Perhaps a candidate for backporting to various branches. Leaving open for now because of this issue.

@hvr
Copy link
Member Author

hvr commented Dec 18, 2014

/cc @tibbe fyi, this may need backporting to 1.18 and 1.20

@hvr
Copy link
Member Author

hvr commented Dec 18, 2014

$ cabal-head install semigroups
Resolving dependencies...
cabal-head: Could not resolve dependencies:
trying: semigroups-0.16 (user goal)
trying: semigroups-0.16:+hashable
trying: semigroups-0.16:+unordered-containers
trying: unordered-containers-0.2.5.1 (dependency of
semigroups-0.16:+unordered-containers)
trying: hashable-1.2.3.0 (dependency of unordered-containers-0.2.5.1)
trying: bytestring-0.10.5.0/installed-a13... (dependency of hashable-1.2.3.0)
trying: semigroups-0.16:+text
rejecting: semigroups-0.16:+deepseq (conflict: bytestring =>
deepseq==1.4.0.0/installed-805..., semigroups-0.16:deepseq => deepseq>=1.1 &&
<1.4)
rejecting: semigroups-0.16:-deepseq (manual flag can only be changed
explicitly)
Backjump limit reached (change with --max-backjumps).

👍 :-)

@ezyang
Copy link
Contributor

ezyang commented Feb 24, 2015

So... how do I manually toggle one of these flags?

@kosmikus
Copy link
Contributor

@ezyang Using either -f or --constraint. So e.g. --constraint="semigroups -hashable".

@ezyang
Copy link
Contributor

ezyang commented Feb 25, 2015

(The key point is, you need to use --constraint to toggle a flag on a specific package.)

@ttuegel ttuegel modified the milestones: Cabal-1.24, Cabal-1.22 Apr 23, 2015
@grayjay
Copy link
Collaborator

grayjay commented Feb 7, 2016

Since the fix hasn't been backported for over a year, can this be closed?

@23Skidoo
Copy link
Member

23Skidoo commented Feb 7, 2016

I guess it can, new cabal-install release will be out soon(ish) anyway.

@23Skidoo 23Skidoo closed this as completed Feb 7, 2016
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

6 participants