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

dependencies are checked even if buildable is False #1725

Closed
bos opened this issue Mar 14, 2014 · 15 comments
Closed

dependencies are checked even if buildable is False #1725

bos opened this issue Mar 14, 2014 · 15 comments

Comments

@bos
Copy link
Contributor

bos commented Mar 14, 2014

I have a little portion of a .cabal file that looks like this:

executable judy
  main-is: Judy.hs

  buildable: False
  ghc-options: -Wall -rtsopts
  build-depends:
    base == 4.*,
    criterion,
    judy -- DELIBERATELY NOT PRESENT

With cabal-install 1.19.2, I get the following error:

    $ cabal configure
    Resolving dependencies...
*** cabal: Could not resolve dependencies:
    trying: criterion-examples-0 (user goal)
*** next goal: judy (dependency of criterion-examples-0)
    Dependency tree exhaustively searched.

This seems weird and non-intuitive and wrong.

@bos
Copy link
Contributor Author

bos commented Mar 14, 2014

Turns out this is an ancient bug, first reported as #224.

@kosmikus
Copy link
Contributor

kosmikus commented Apr 3, 2014

It's unclear if the old bug is really the same. I've done a quick test, and fixing it in the modular solver itself is nearly trivial. However, cabal-install performs a sanity check on the build plan the solver produces, and omitting the dependencies for non-buildable components from the build plan causes the sanity check to fail. I'm somewhat less familiar with that code, but I'll try to look at it.

Another potential option is to filter out the non-buildable components from the index before even passing the index to the solver, but that seems like a hack.

@TomMD
Copy link
Contributor

TomMD commented Jun 16, 2014

Judging by the age, am I correct in assuming no one is working this bug and no solution has been agreed upon? This bug hinders any cross compilation (ios, android, halvm) project. If someone is willing to give a pointer on solution method then I'll look into making a patch and pull request.

acw added a commit to GaloisInc/SHA that referenced this issue Jun 16, 2014
@kosmikus
Copy link
Contributor

This had indeed dropped off my radar again. I'm currently travelling, but I'll try to make another attempt next week. Of course, if someone else wants to fix it in the meantime, feel free to do so.

@kosmikus kosmikus self-assigned this Jun 17, 2014
@tibbe tibbe added the solver label Jun 17, 2014
@nh2
Copy link
Member

nh2 commented Oct 13, 2014

I'm also suffering from this problem. @kosmikus, are you still interested in working on it?

@snoyberg
Copy link
Collaborator

I just got bit by this too. (Thanks @23Skidoo for so quickly pointing out that it was a dupe.) However, I think the "solver" label is not correct: using runghc Setup.hs configure can trigger this behavior too.

@mietek
Copy link
Contributor

mietek commented Jul 18, 2015

Another way to reproduce this bug:

cabal install -v3 --dry-run cheapskate-0.1.0.4

This shouldn’t pull in wai or wai-extra, as they’re dependencies for cheapskate-dingus, which isn’t buildable by default.

@dcoutts
Copy link
Contributor

dcoutts commented Jul 18, 2015

There's a little bit of history to this one. We had a patch (for the Cabal lib) to try to avoid non-buildable packages contributing to deps but doing so broke things in subtle ways and we had to revert it. I can't remember the details off the top of my head. The patch should be there in the git history if you look for "buildable".

@ntc2
Copy link

ntc2 commented Jul 21, 2015

Me too.

ntc2 referenced this issue in GaloisInc/cryptol Jul 21, 2015
Brings the JSON over ZeroMQ server into the main line of development. It
is disabled by default, but there is now a `server` flag in
`cryptol.cabal` that in turn gets enabled if the `CRYPTOL_SERVER`
environment variable is nonempty during `make`.
@phadej
Copy link
Collaborator

phadej commented Jul 22, 2015

The commit @dcoutts mentioned: 04dff51

@hvr
Copy link
Member

hvr commented Jul 22, 2015

am I right, that the current backward compat workaround is to use a manual flag, e.g.

flag build_judy
  manual: True
  default: False

executable judy
  main-is: Judy.hs

  if !flag(build_judy)
    buildable: False
  ghc-options: -Wall -rtsopts
  if flag(build_judy)
    build-depends:
      base == 4.*,
      criterion,
      judy -- DELIBERATELY NOT PRESENT

?

@ntc2
Copy link

ntc2 commented Jul 22, 2015

@hvr: I think the important thing in your example is that you guarded the build-depends with the if flag(build_judy). That works! And it still works if I remove the manual: True on the flag. THANKS!

Complete example that actually builds:

name: needs-judy
version: 0
build-type: Simple
cabal-version: >= 1.2

flag build_judy
  default: False

library

executable judy
  main-is: Judy.hs

  ghc-options: -Wall -rtsopts
  if flag(build_judy)
    build-depends:
      -- DELIBERATELY NOT PRESENT
      judy
  else
    buildable: False

assuming a default Setup.hs containing:

import Distribution.Simple
main = defaultMain

acfoltzer added a commit to GaloisInc/cryptol that referenced this issue Jul 22, 2015
Only require cryptol-server's build depends when it's being built. Workaround for haskell/cabal#1725
@kosmikus
Copy link
Contributor

The workaround that @hvr provides should indeed be ok.

I've also been working on this. Pull request (not very thoroughly tested) will follow in a few minutes.

@ezyang
Copy link
Contributor

ezyang commented Dec 21, 2015

The change (that got reverted) is a0ca303

To state it more clearly, the bug is that when we flatten the package description, the set of package-global dependencies we compute blindly gobbles up all of the build-depends, regardless of the status of the buildable flag. I don't know what the subtle problem could be.

@grayjay
Copy link
Collaborator

grayjay commented Jan 15, 2016

This was fixed in #3039.

trofi added a commit to gentoo-haskell/gentoo-haskell that referenced this issue Apr 11, 2016
Workarounds Cabal-1.22 bug haskell/cabal#1725

Package-Manager: portage-2.2.28
trofi pushed a commit to gentoo-haskell/gentoo-haskell that referenced this issue Feb 22, 2017
…#610422

Workarounds Cabal-1.22 bug
    haskell/cabal#1725

Reported-by: Peter Bleszynski
Bug: https://bugs.gentoo.org/610422

Package-Manager: Portage-2.3.3, Repoman-2.3.1
gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Feb 22, 2017
…#610422

Workarounds Cabal-1.22 bug
    haskell/cabal#1725

Reported-by: Peter Bleszynski
Bug: https://bugs.gentoo.org/610422

Package-Manager: Portage-2.3.3, Repoman-2.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.