Closed snoyberg closed 9 years ago
/cc @kosmikus
I'm also having trouble with transformers-compat
. See for instance https://travis-ci.org/diagrams/diagrams-cairo/jobs/25420386 starting around line 342. It looks as though Cabal never tries transformers-compat-0.3:+transformers3
(which is what I'd like to install), and instead falls back to transformers-compat-0.1.1
, which had fewer flags.
This looks worrying. To summarize: it shouldn't happen that a solution is
found with --reorder-goals
, but no solution is found without, and the
tree has been searched exhaustively.
I suspect a subtle bug in the computation or interpretation of conflict sets during backjumping.
I will look into this.
I encountered the same issue. The following cabal file seems to reproduce the problem:
name: test
version: 0.1
build-type: Simple
cabal-version: >= 1.10
library
default-language: Haskell2010
build-depends:
base >= 4.6 && < 4.8
, errors == 1.4.7
Ok, I cannot tell yet whether all of this is the same issue. But I can say that I've tracked down the cause of what @bergey describes to a combination of two issues that, once solved, may or may not fix the others, too.
One issue is that manual flags may under certain circumstances cause parts of the search tree to be discarded. The flag transformers2
in transformers-compat
is such a flag. This one is trivial to fix.
The other issue is that flag dependencies are not properly taken into account when computing conflict sets. Here, transformers2
depends on transformers3
, because it appears in a nested if
-statement in the Cabal file. This bug is easy to work around in a conservative way that makes it clear to me that this is indeed the culprit. However, the fix is a hack and may cause performance problems in unrelated areas. I'm working on fixing it properly now. Once I've done that, I'll try to figure out whether that fixes the other problems described here.
@kosmikus This sounds like an issue @cartazio opened against text-stream-decode (https://github.com/fpco/text-stream-decode/issues/1). I'm not sure if he ever turned it into a cabal-install issue, so linking to it here in case it helps.
@snoyberg @cartazio From a quick look, it seems as if fpco/text-stream-decode#1 is more related to https://github.com/bos/aeson/issues/177 and #1831 than this one.
Some more comments: The problem by @bergey should be fixed by the pull request I just sent. The test case provided by @twittner, too (thanks!). It should also fix the related problem reported on the cabal-devel mailing list today by Björn Peemöller (http://www.haskell.org/pipermail/cabal-devel/2014-May/009795.html). I cannot check the original test case provided by @snoyberg easily, but at least it should no longer report "Dependency tree exhaustively searched." It could still be that --max-backjumps=-1
takes significantly longer than --reorder-goals
, though, or leads to a different (yet technically also valid) install plan.
The keter problem reported by @snoyberg in #1877 is not fixed by this. This looks like it's caused by "strong flag handling" instead, which is related to bos/aeson#177 and #1831 (and, as @snoyberg pointed out earlier, probably to fpco/text-stream-decode#1, too). I'll say more about this soon.
I am also seeing something like this with ihaskell
and cabal-install version 1.20. If you create an empty sandbox and do cabal install ihaskell --reorder-goals
it works, but if you don't have the flag you get a dependency tree exhaustively searched
message and it dies.
See outputs for these two cases here: https://gist.github.com/gibiansky/a865467338945ece890c
@gibiansky This is just exactly the same issue, even triggered by the same package again (transformers-compat
), so pull request #1878 should fix it.
@kosmikus Alright, cool, glad there's a fix on the way.
Practically, if I were to remove the transformers2
flag from the package giving up on GHC 7.0.x would that resolve this issue?
@ekmett It would probably fix the issue without people having to upgrade cabal-install
, yes. But I haven't really looked at the problem from this perspective yet. I can try to think about whether there's a "better" change for transformers-compat
that would still work around this problem.
Thanks. I need to get this to work for users with older cabals as well, because of the very purpose of the package, so if I'm forced into releasing a suboptimal version of the package simply to fix the issue, then I guess that is just the price I have to pay.
@ekmett It's a maintenance nightmare, but...
What about releasing three versions of transformers-compat:
transformers == 0.2.*
transformers == 0.3.*
transformers == 0.4.*
And then cabal will simply select which of those three versions it uses based on the version of transformers. I think that will address the current problem.
@ekmett What @snoyberg suggests should work. Another option I could think of is to go to two separate transformers-compat packages, each with just one flag. One (let's call it t4
makes the decision between version 4 or else (and either depends on transformers == 0.4.*
or on t3
). The other (t3
) makes the decision between version 3 or lower (and either depends on transformers == 0.3.*
or on `transformers == 0.2.*
. This way, you also avoid the nested flags.
I could go for that solution if it is the only thing that works.
That said, it'd be a deliberately breaking @mightybyte's "implicit blacklisting" notion.
http://softwaresimply.blogspot.com/2014/05/implicit-blacklisting-for-cabal.html
If we did that on the minor version instead then his notion would still remain intact.
-Edward
On Tue, May 20, 2014 at 10:47 AM, Michael Snoyman notifications@github.comwrote:
@ekmett https://github.com/ekmett It's a maintenance nightmare, but...
What about releasing three versions of transformers-compat:
- Version 0.3.3.1 will have a dependency transformers == 0.2.*
- Version 0.3.3.2 will have a dependency transformers == 0.3.*
- Version 0.3.3.3 will have a dependency transformers == 0.4.*
And then cabal will simply select which of those three versions it uses based on the version of transformers. I think that will address the current problem.
— Reply to this email directly or view it on GitHubhttps://github.com/haskell/cabal/issues/1855#issuecomment-43635727 .
Minor version instead of patch seems fine to me. I didn't have any strong reason for one vs the other.
I also encountered the flag issue, with ghc-7.8.2
, cabal-install-1.20.0.2
, and the following package description, generated by the snap
scaffolding tool. Removing all mentions of the old-base
flag from the package description helped me, however, specifying --reorder-goals
did not.
Name: snap-test
Version: 0.1
Synopsis: Project Synopsis Here
Description: Project Description Here
License: AllRightsReserved
Author: Author
Maintainer: maintainer@example.com
Stability: Experimental
Category: Web
Build-type: Simple
Cabal-version: >=1.2
Flag development
Description: Whether to build the server in development (interpreted) mode
Default: False
Flag old-base
default: False
manual: False
Executable snap-test
hs-source-dirs: src
main-is: Main.hs
Build-depends:
bytestring >= 0.9.1 && < 0.11,
heist >= 0.13 && < 0.14,
MonadCatchIO-transformers >= 0.2.1 && < 0.4,
mtl >= 2 && < 3,
snap >= 0.13 && < 0.14,
snap-core >= 0.9 && < 0.11,
snap-server >= 0.9 && < 0.11,
snap-loader-static >= 0.9 && < 0.10,
snaplet-postgresql-simple >= 0.5 && < 0.6,
text >= 0.11 && < 1.2,
time >= 1.1 && < 1.5,
xmlhtml >= 0.1
if flag(old-base)
build-depends:
base >= 4 && < 4.4,
lens >= 3.7.6 && < 3.8
else
build-depends:
base >= 4.4 && < 5,
lens >= 3.7.6 && < 4.2
if flag(development)
build-depends:
snap-loader-dynamic == 0.10.*
cpp-options: -DDEVELOPMENT
-- In development mode, speed is already going to suffer, so skip
-- the fancy optimization flags. Additionally, disable all
-- warnings. The hint library doesn't give an option to execute
-- compiled code when there were also warnings, so disabling
-- warnings allows quicker workflow.
ghc-options: -threaded -w
else
if impl(ghc >= 6.12.0)
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
-fno-warn-orphans -fno-warn-unused-do-bind
else
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
-fno-warn-orphans
Symptoms:
cabal: Could not resolve dependencies:
trying: snap-test-0.1 (user goal)
trying: lens-4.1.2.1 (dependency of snap-test-0.1)
trying: transformers-compat-0.3.3 (dependency of lens-4.1.2.1)
trying: transformers-0.3.0.0/installed-7df... (dependency of lens-4.1.2.1)
rejecting: transformers-compat-0.3.3:-two (conflict:
transformers==0.3.0.0/installed-7df..., transformers-compat-0.3.3:two =>
transformers>=0.4.1 && <0.5)
rejecting: transformers-compat-0.3.3:+two (conflict:
transformers==0.3.0.0/installed-7df..., transformers-compat-0.3.3:two =>
transformers>=0.2 && <0.3)
Backjump limit reached (change with --max-backjumps).
@mietek Thanks for the report, but this is not the same issue. The original problem was that a build plan was not found in a situation where one existed. Your example is just one that takes longer (and more backjumps) than the pre-set backjump limit. It's indeed curious that computing a build plan for this package takes so long without --reorder-goals
, but I've just verified that it does indeed compute ultimately, so it's a performance bug, not a completeness bug. See #1780 about more discussion on --reorder-goals
. I'm inclined to close this bug, because it's already confusing enough with all the discussion, and the original issue is now fixed. We could open a new bug reminding us that we should try to enhance the default heuristics to improve overall performance and avoid cases such as this one.
@mietek Hmm. While it's qualitatively not the same, there's still something strange going on which may potentially be related to the original bug not being properly fixed. Leaving this open for now, will investigate further asap.
@mietek Ok, unfortunately I'm now certain that there's still a bug related to the original issue, and that the fix in cabal-install-1.20.0.2
is, as sad as it is, incomplete. Apologies for doubting you :) I'll need to think about this carefully. I don't want to fix this improperly again, and the fact that the first fix wasn't complete shows that I've clearly underestimated the complexity of the underlying problem. In the short term, if you run into any issues, a workaround is still to set the flags of the transformers-compat
package explicitly, via --constraint
.
@kosmikus @ekmett I had to add a patch to Stackage about this recently as well. Edward: is there any chance of getting some patched versions of transformers-compat onto Hackage as we discussed earlier in this issue?
Now that it is clear that the elegant version, which was going to be a third of the maintenance effort will not work; yes. ;)
I am not fully convinced that a further patch to transformers-compat is necessary. For all I can see, the latest version Edward uploaded fixes the issue for all older cabal-install versions, but ironically breaks once again for 1.20.0.2 (Edward's and my hack and my apparently improper fix cancel each other out). So everyone who is reluctant to upgrade cabal-install is probably fine right now (if not, please let me know more details). Those who are not reluctant to upgrade will probably also upgrade again once I fix this (and this time, hopefully, properly).
Fair enough. I'll hold back and let you come up with a fix.
On Thu, May 29, 2014 at 5:51 PM, kosmikus notifications@github.com wrote:
I am not fully convinced that a further patch to transformers-compat is necessary. For all I can see, the latest version Edward uploaded fixes the issue for all older cabal-install versions, but ironically breaks once again for 1.20.0.2 (Edward's and my hack and my apparently improper fix cancel each other out). So everyone who is reluctant to upgrade cabal-install is probably fine right now (if not, please let me know more details). Those who are not reluctant to upgrade will probably also upgrade again once I fix this (and this time, hopefully, properly).
— Reply to this email directly or view it on GitHub https://github.com/haskell/cabal/issues/1855#issuecomment-44590216.
Just to throw in some more data:
$ cabal --version
cabal-install version 1.18.0.4
using version 1.18.1.3 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.2
$ cabal install transformers-compat-0.3.3.4 --constraint 'transformers < 0.4'
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: transformers-compat-0.3.3.4 (user goal)
trying: transformers-compat-0.3.3.4:-three
next goal: transformers (dependency of transformers-compat-0.3.3.4)
rejecting: transformers-0.3.0.0/installed-7df... (conflict:
transformers-compat-0.3.3.4:three => transformers>=0.4.1 && <0.5)
rejecting: transformers-0.4.1.0, 0.4.0.0 (global constraint requires <0.4)
rejecting: transformers-0.3.0.0, 0.2.2.1, 0.2.2.0, 0.2.1.0, 0.2.0.0, 0.1.4.0,
0.1.3.0, 0.1.1.0, 0.1.0.1, 0.1.0.0, 0.0.1.0, 0.0.0.0 (conflict:
transformers-compat-0.3.3.4:three => transformers>=0.4.1 && <0.5)
Dependency tree exhaustively searched.
ubuntu@picard-precise:~$ cabal version
cabal: unrecognised command: version (try --help)
And:
~$ cabal --version
cabal-install version 1.20.0.2
using version 1.20.0.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.2
$ cabal install transformers-compat-0.3.3.4 --constraint 'transformers < 0.4'
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: transformers-compat-0.3.3.4 (user goal)
trying: transformers-compat-0.3.3.4:-three
next goal: transformers (dependency of transformers-compat-0.3.3.4)
rejecting: transformers-0.3.0.0/installed-7df... (conflict:
transformers-compat-0.3.3.4:three => transformers>=0.4.1 && <0.5)
rejecting: transformers-0.4.1.0, 0.4.0.0 (global constraint requires <0.4)
rejecting: transformers-0.3.0.0, 0.2.2.1, 0.2.2.0, 0.2.1.0, 0.2.0.0, 0.1.4.0,
0.1.3.0, 0.1.1.0, 0.1.0.1, 0.1.0.0, 0.0.1.0, 0.0.0.0 (conflict:
transformers-compat-0.3.3.4:three => transformers>=0.4.1 && <0.5)
Dependency tree exhaustively searched.
I just ran into this when trying to update a customer's codebase to newer package versions. My current workaround is patching transformers-compat in Stackage to avoid any conditionals (since in Stackage, we're pegged at transformers-0.3.0.0).
@snoyberg This latest behaviour you're reporting is correct. In transformers-compat-0.3.3.4
, the flags two
and three
are both set to manual
, and they're both False
by default, which means a dependency on transformers >= 0.4.1
which in combination with your explicit constraint simply cannot be resolved.
Something like
cabal install transformers-compat
--constraint 'transformers < 0.4'
--constraint 'transformers-compat >= 0.3.3'
should work
Yes, my mistake with the overly restrictive bounds. The transformers-compat issue does seem to be resolved now.
How is this resolved? I try installing ad in a fresh sandbox and it fails with
$ cabal install ad
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ad-4.2.0.1 (user goal)
trying: transformers-0.3.0.0/installed-da9... (dependency of ad-4.2.0.1)
trying: free-4.7.1 (dependency of ad-4.2.0.1)
trying: semigroupoids-4.0.2 (dependency of free-4.7.1)
trying: contravariant-0.5.2 (dependency of semigroupoids-4.0.2)
trying: transformers-compat-0.3 (dependency of contravariant-0.5.2)
rejecting: transformers-compat-0.3:-transformers2 (conflict:
transformers==0.3.0.0/installed-da9..., transformers-compat-0.3:transformers2
=> transformers>=0.4 && <0.5)
rejecting: transformers-compat-0.3:+transformers2 (conflict:
transformers==0.3.0.0/installed-da9..., transformers-compat-0.3:transformers2
=> transformers>=0.2 && <0.3)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
But all is well if I do
$ cabal install ad --reorder-goals
Resolving dependencies...
Notice: installing into a sandbox located at
.cabal-sandbox
Downloading data-reify-0.6...
Configuring erf-2.0.0.0...
Downloading prelude-extras-0.4...
Configuring nats-0.1.3...
Building nats-0.1.3...
Building erf-2.0.0.0...
Configuring data-reify-0.6...
Downloading tagged-0.7.2...
Downloading transformers-compat-0.3...
Configuring prelude-extras-0.4...
Building data-reify-0.6...
Building prelude-extras-0.4...
Installed erf-2.0.0.0
Configuring tagged-0.7.2...
Configuring transformers-compat-0.3...
Installed nats-0.1.3
Building tagged-0.7.2...
Building transformers-compat-0.3...
Configuring semigroups-0.12.2...
Installed data-reify-0.6
Building semigroups-0.12.2...
Installed prelude-extras-0.4
Installed tagged-0.7.2
Downloading reflection-1.4...
Configuring reflection-1.4...
Building reflection-1.4...
Installed reflection-1.4
Installed transformers-compat-0.3
Downloading contravariant-0.5.2...
Downloading distributive-0.4.4...
Configuring distributive-0.4.4...
Configuring contravariant-0.5.2...
Building contravariant-0.5.2...
Building distributive-0.4.4...
Installed contravariant-0.5.2
Installed distributive-0.4.4
Installed semigroups-0.12.2
Downloading comonad-4.0.1...
Configuring comonad-4.0.1...
Building comonad-4.0.1...
Installed comonad-4.0.1
Downloading semigroupoids-4.0.2...
Configuring semigroupoids-4.0.2...
Building semigroupoids-4.0.2...
Installed semigroupoids-4.0.2
Downloading bifunctors-4.1.1.1...
Downloading profunctors-4.0.4...
Configuring bifunctors-4.1.1.1...
Configuring profunctors-4.0.4...
Building bifunctors-4.1.1.1...
Building profunctors-4.0.4...
Installed profunctors-4.0.4
Installed bifunctors-4.1.1.1
Downloading free-4.7.1...
Configuring free-4.7.1...
Building free-4.7.1...
Installed free-4.7.1
Downloading ad-4.2.0.1...
Configuring ad-4.2.0.1...
Building ad-4.2.0.1...
Installed ad-4.2.0.1
What version of cabal-install
is this? Also, do you have the latest Hackage data? It's strange that free-4.7.1
is selected despite free-4.9
being available, and it's also strange that transformers-compat-0.3
is selected despite later versions being available.
cabal-install version 1.18.0.3
using version 1.18.1.3 of the Cabal library
I am using stackage not hackage
remote-repo: ghc78alpha:http://www.stackage.org/alias/fpcomplete/ghc78-alpha
There are two things which, together, are causing this problem:
Why don't we follow up privately about the best way to address this issue (either moving to a new snapshot, or upgrading cabal-install). Can you email me?
Ok following up privately.
I think only 1.20.0.3 and 1.18.0.5 are truly ok as far as cabal-install is concerned.
@kosmikus I think you're right, but for this specific bug, I think 1.18.0.4 does not reproduce the issue.
@snoyberg Quite possible. I'm just saying that if anyone is taking the effort to upgrade cabal-install
, they should rather go to 1.18.0.5, because 1.18.0.4 is known to still be buggy.
More data:
$ cabal --version
cabal-install version 1.22.0.0
using version 1.22.0.0 of the Cabal library
$ cabal install buildwrapper scion-browser hoogle stylish-haskell hlint
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: buildwrapper-0.9.1 (user goal)
trying: conduit-extra-1.1.6.2 (dependency of buildwrapper-0.9.1)
trying: streaming-commons-0.1.9.1 (dependency of conduit-extra-1.1.6.2)
trying: random-1.1 (dependency of streaming-commons-0.1.9.1)
trying: aeson-0.8.0.2 (dependency of buildwrapper-0.9.1)
trying: template-haskell-2.9.0.0/installed-6d2... (dependency of
aeson-0.8.0.2)
trying: scion-browser-0.5.0 (user goal)
next goal: parallel-io (dependency of scion-browser-0.5.0)
rejecting: parallel-io-0.3.3, 0.3.2.2, 0.3.2.1 (conflict: random==1.1,
parallel-io => random>=1.0 && <1.1)
rejecting: parallel-io-0.3.2, 0.3.1, 0.3.0.2, 0.3.0.1 (conflict:
template-haskell => containers==0.5.5.1/installed-d4b..., parallel-io =>
containers>=0.2 && <0.5)
rejecting: parallel-io-0.3.0 (conflict: template-haskell =>
containers==0.5.5.1/installed-d4b..., parallel-io => containers>=0.3 && <0.4)
rejecting: parallel-io-0.2.2, 0.2.1.1, 0.2.1, 0.2 (conflict: scion-browser =>
parallel-io>=0.3)
Backjump limit reached (change with --max-backjumps).
While with --reorder-goals
it works.
@neothemachine you should test that with --max-backjumps=-1
, it stopped before the search space was exhausted.
Well, after 15min of 100% CPU usage and 3.5GiB memory usage I killed cabal-install.
On 02/09/2015 06:35 PM, Adam Bergmark wrote:
@neothemachine https://github.com/neothemachine you should test that with --max-backjumps=-1, it stopped before the search space was exhausted.
— Reply to this email directly or view it on GitHub https://github.com/haskell/cabal/issues/1855#issuecomment-73552269.
Sorry for not following up properly on this. I actually believe this is fixed since 5b63fce601997009376522c5de9b11275c3681ee. I'm closing this bug. If after that there are still problems, please reopen or better, open a new issue.
(And because several things are mixed up in this thread, let me just reiterate: Adding or removing --reorder-goals
may affect the time needed to find a solution dramatically. While this is unfortunate, it's not, strictly speaking, a bug. It's the reason this flag exists in the first place. It is a bug if without --reorder-goals
, no solution is found with Dependency tree exhaustively searched.
, and with the flag, there suddenly is a solution; or the other way round.)
I apologize if this is somewhat off-topic. Why not have cabal automatically fall back to reordering goals in the event of the dependency tree being exhaustively searched? If one is supposed to try adding the --reorder-goals
flag after getting that error, it seems like it'd be good if cabal just did it without intervention.
@altaic because it is a bug (that needs to be fixed rather than workarounded). The set of solutions is supposed to be equal whether you give --reorder-goals
or not. It's just a different traversal of the same space.
In my Stackage builds, I use --max-backjumps=-1 --reorder-goals. Given the recent discussion about reorder-goals both being slow, and possibly causing non-termination in build plan construction, I decided to try out running the build without --reorder-goals. However, doing so caused the build plan to fail. Following is the command I ran, and the output from cabal.
Note that there are some local, patched versions of libraries I'm using here. These patches are all available in the Stackage repo, and I can additionally provide them directly if that would be useful.