Using cabal-install 2.2, I do cabal init and change build-type to Custom. My cabal file is accepted but I get the following error from the resolver:
$ cabal new-build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: test-cabal-custom-0.1.0.0 (user goal)
[__1] next goal: test-cabal-custom:setup.Cabal (dependency of
test-cabal-custom)
[__1] rejecting: test-cabal-custom:setup.Cabal-2.2.0.0/installed-2.2...,
test-cabal-custom:setup.Cabal-2.2.0.1, test-cabal-custom:setup.Cabal-2.2.0.0
(conflict: test-cabal-custom => test-cabal-custom:setup.Cabal>=1.10 && <1.25)
[__1] rejecting: test-cabal-custom:setup.Cabal-2.0.1.1,
test-cabal-custom:setup.Cabal-2.0.1.0, test-cabal-custom:setup.Cabal-2.0.0.2,
test-cabal-custom:setup.Cabal-1.24.2.0,
test-cabal-custom:setup.Cabal-1.24.0.0,
test-cabal-custom:setup.Cabal-1.22.8.0,
test-cabal-custom:setup.Cabal-1.22.7.0,
test-cabal-custom:setup.Cabal-1.22.6.0,
test-cabal-custom:setup.Cabal-1.22.5.0,
test-cabal-custom:setup.Cabal-1.22.4.0,
test-cabal-custom:setup.Cabal-1.22.3.0,
test-cabal-custom:setup.Cabal-1.22.2.0,
test-cabal-custom:setup.Cabal-1.22.1.1,
test-cabal-custom:setup.Cabal-1.22.1.0,
test-cabal-custom:setup.Cabal-1.22.0.0,
test-cabal-custom:setup.Cabal-1.20.0.4,
test-cabal-custom:setup.Cabal-1.20.0.3,
test-cabal-custom:setup.Cabal-1.20.0.2,
test-cabal-custom:setup.Cabal-1.20.0.1,
test-cabal-custom:setup.Cabal-1.20.0.0,
test-cabal-custom:setup.Cabal-1.18.1.7,
test-cabal-custom:setup.Cabal-1.18.1.6,
test-cabal-custom:setup.Cabal-1.18.1.5,
test-cabal-custom:setup.Cabal-1.18.1.4,
test-cabal-custom:setup.Cabal-1.18.1.3,
test-cabal-custom:setup.Cabal-1.18.1.2,
test-cabal-custom:setup.Cabal-1.18.1.1, test-cabal-custom:setup.Cabal-1.18.1,
test-cabal-custom:setup.Cabal-1.18.0, test-cabal-custom:setup.Cabal-1.16.0.3,
test-cabal-custom:setup.Cabal-1.16.0.2,
test-cabal-custom:setup.Cabal-1.16.0.1, test-cabal-custom:setup.Cabal-1.16.0,
test-cabal-custom:setup.Cabal-1.14.0, test-cabal-custom:setup.Cabal-1.12.0,
test-cabal-custom:setup.Cabal-1.10.2.0,
test-cabal-custom:setup.Cabal-1.10.1.0,
test-cabal-custom:setup.Cabal-1.10.0.0, test-cabal-custom:setup.Cabal-1.8.0.6,
test-cabal-custom:setup.Cabal-1.8.0.4, test-cabal-custom:setup.Cabal-1.8.0.2,
test-cabal-custom:setup.Cabal-1.6.0.3, test-cabal-custom:setup.Cabal-1.6.0.2,
test-cabal-custom:setup.Cabal-1.6.0.1, test-cabal-custom:setup.Cabal-1.4.0.2,
test-cabal-custom:setup.Cabal-1.4.0.1, test-cabal-custom:setup.Cabal-1.4.0.0,
test-cabal-custom:setup.Cabal-1.2.4.0, test-cabal-custom:setup.Cabal-1.2.3.0,
test-cabal-custom:setup.Cabal-1.2.2.0, test-cabal-custom:setup.Cabal-1.2.1,
test-cabal-custom:setup.Cabal-1.1.6, test-cabal-custom:setup.Cabal-1.24.1.0
(constraint from minimum version of Cabal used by Setup.hs requires >=2.2)
[__1] fail (backjumping, conflict set: test-cabal-custom,
test-cabal-custom:setup.Cabal)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: test-cabal-custom:setup.Cabal,
test-cabal-custom
For some reason, it implicitly picks Cabal <1.25 as a constraint. Adding this stanza works:
setup-depends: Cabal, base
I did find this in the docs:
Since Cabal 1.24, custom Setup.hs are required to accurately track their dependencies by declaring them in the .cabal file rather than rely on dependencies being implicitly in scope.
So is this just a case of cabal not giving an error message on my incorrect .cabal file?
This is working as it's supposed to, do you think the error message should be improved?
It wasn't at all clear to me from the output why the Cabal<1.25 constraint was introduced. Printing some extra info along the lines of "No "custom-setup" stanza defined in cabal file, assuming Cabal < 1.25" would be very helpful.
@jaccokrijnen what did cabal check say?
@hvr cabal check indeed mentions the stanza:
- From version 1.24 cabal supports specifiying explicit dependencies for
Custom setup scripts. Consider using cabal-version >= 1.24 and adding a
'custom-setup' section with a 'setup-depends' field that specifies the
dependencies of the Setup.hs script itself. The 'setup-depends' field uses the
same syntax as 'build-depends', so a simple example would be 'setup-depends:
base, Cabal'.
But when just building the project it would be really nice to have some line of text on why the Cabal < 1.25 is added.
I'd be happy to help and implement it. I was looking through the code if there was an easy way to attach an explanation to the introduced dependency or just print a message. The constraint is introduced in cabal-install/Distribution/Solver/Modular/Dependency.hs:
defaultSetupDeps :: Compiler -> Platform -> PD.PackageDescription -> Maybe [Dependency]
which in turn is applied to every source package with no setupBuildInfo and with custom setup (in addDefaultSetupDependencies). That happens as a part of this pure DepResolverParams -> DepResolverParams composition in ProjectPlanning.hs (planPackages). How would you recommend to log these kind of messages? Keeping a Map Dependency Explanation around in DepResolverParams doesn't really seem right.
maybe @grayjay can provide a suggestion
Did you mean defaultSetupDeps in Distribution.Client.ProjectPlanning? We could move that index transformation into Distribution.Solver.Modular.IndexConversion, where the solver converts GenericPackageDescriptions to the solver's package type, and then add labels to packages' dependencies in the solver's format. The labels could be used similarly to the existing labels for package constraints:
Labels on constraints are only printed when they lead to conflicts in the solver, so they can help to explain a failure. For example, cabal shows that the < 0.1 constraint came from a command line flag:
$ cabal install vector-algorithms --dry-run --constraint="vector < 0.1"
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: vector-algorithms-0.7.0.1 (user goal)
[__1] next goal: vector (dependency of vector-algorithms)
[__1] rejecting: vector-0.12.0.1, vector-0.12.0.0, vector-0.11.0.0,
vector-0.10.12.3, vector-0.10.12.2, vector-0.10.12.1, vector-0.10.11.0,
vector-0.10.10.0, vector-0.10.9.2, vector-0.10.9.1, vector-0.10.9.0,
vector-0.10.0.1, vector-0.10, vector-0.9.1, vector-0.9, vector-0.8,
vector-0.7.1, vector-0.7.0.1, vector-0.7, vector-0.6.0.2, vector-0.6.0.1,
vector-0.6, vector-0.5, vector-0.4.2, vector-0.4.1, vector-0.4, vector-0.3.1,
vector-0.3, vector-0.2, vector-0.1, vector-0.10.12.0, vector-0.10.9.3
(constraint from command line flag requires <0.1)
[__1] fail (backjumping, conflict set: vector, vector-algorithms)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: vector, vector-algorithms
Another possible solution is to perform a check similar to cabal check on the local packages before running the solver. That type of warning would be more visible, though it wouldn't explain conflicts that involve other packages.
Most helpful comment
It wasn't at all clear to me from the output why the Cabal<1.25 constraint was introduced. Printing some extra info along the lines of "No "custom-setup" stanza defined in cabal file, assuming Cabal < 1.25" would be very helpful.