commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.99k stars 845 forks source link

Support conditional build dependencies in cabal files #589

Closed conklech closed 9 years ago

conklech commented 9 years ago

I'm not sure whether this is an issue with stack or something else.

I'm trying to build reflex-dom with stack. It depends on ghcjs-dom, which has a conditional dependency on ghcjs-base that should not be triggered when building with ghc. The condition is if impl(ghcjs) && flag(jsffi).

With a stack.yaml file that specifies ghcjs-dom-0.1.1.3 in the extra-deps, I get the following error:

--  While attempting to add dependency,
    Could not find package ghcjs-base in known packages

--  Failure when adding dependencies:
      ghcjs-base: needed (-any), but not present in build plan
    needed for package: ghcjs-dom-0.1.1.3

When building with GHC, ghcjs-base should not be required by ghcjs-dom. I tried to override this requirement by manually setting the flag jsffi to false in stack.yaml, which also should eliminate the ghcjs-base dependency, but that does does not change anything:

flags: 
  ghcjs-dom:
    webkit: true
    jsffi: false
snoyberg commented 9 years ago

I think you're seeing the outcome of #50, which is a workaround in stack for a long standing Cabal bug.

conklech commented 9 years ago

Does Cabal only handle conditional dependencies using buildable? If so, I guess #50 could cause this behavior.

Since I've removed all my non-stack build tooling, I can't easily test this with cabal-install. I guess I've assumed that ghcjs-dom is actually buildable with GHC/cabal-install, which is an advertised feature.

snoyberg commented 9 years ago

I may have been mistaken, I'm not sure. I'll be able to check later when I'm at a keyboard again.

conklech commented 9 years ago

Let me know if you'd like me to prepare a minimal test case.

snoyberg commented 9 years ago

A minimal test case would certainly be helpful. Also, seeing your stack.yaml file from the original report would also be useful.

snoyberg commented 9 years ago

FYI, the following worked for me:

flags:
  text:
    integer-simple: false
  ghcjs-dom:
    ghcjs: false
extra-deps:
- StateVar-1.1.0.0
- adjunctions-4.2.1
- aeson-0.8.1.1
- attoparsec-0.13.0.1
- bifunctors-4.2.1
- cairo-0.13.1.0
- comonad-4.2.6
- contravariant-1.3.1.1
- data-default-0.5.3
- data-default-class-0.0.1
- data-default-instances-base-0.0.1
- data-default-instances-containers-0.0.1
- data-default-instances-dlist-0.0.1
- data-default-instances-old-locale-0.0.1
- dependent-map-0.1.1.3
- dependent-sum-0.2.1.0
- distributive-0.4.4
- dlist-0.7.1.1
- exceptions-0.8.0.2
- free-4.12.1
- ghcjs-dom-0.1.1.3
- gio-0.13.1.0
- glib-0.13.1.1
- gtk3-0.13.9
- hashable-1.2.3.3
- kan-extensions-4.2.2
- lens-4.9.1
- mtl-2.2.1
- nats-1
- old-locale-1.0.0.7
- pango-0.13.1.0
- parallel-3.2.0.6
- prelude-extras-0.4
- primitive-0.6
- profunctors-4.4.1
- ref-tf-0.4
- reflection-1.5.2.1
- reflex-0.2
- safe-0.3.9
- scientific-0.3.3.8
- semigroupoids-4.3
- semigroups-0.16.2.2
- stm-2.4.4
- syb-0.5.1
- tagged-0.8.1
- text-1.2.1.1
- these-0.4.1
- transformers-compat-0.4.0.4
- unordered-containers-0.2.5.1
- utf8-string-1
- vector-0.10.12.3
- void-0.7
- webkitgtk3-0.13.1.3
- webkitgtk3-javascriptcore-0.13.0.4
resolver: ghc-7.10
conklech commented 9 years ago

Hmph. I'm a dummy; I was looking at the .cabal file on Github for version 0.2.*; the version in both our buildplans, 0.1.1.3, uses the ghcjs flag instead. Thanks for the build plan.

Closed: NOTABUG. Sorry for the distraction.

snoyberg commented 9 years ago

No problem