Repository navigation
Description
I am running:
cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library
on OSX 10.9.5
with GCH 7.8.3 and the haskell platform 2014.2
I have a very simple .cabal file that builds two executables:
------------------------------------------------
name: agent
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.20
----------------------------------------------
executable myPersonalMain
main-is: Mpm.hs
hs-source-dirs: ./test
ghc-options: -main-is Mpm
build-depends:
base >=4.4
default-language: Haskell2010
----------------------------------------------
executable agent
main-is: Main.hs
hs-source-dirs: ./src
build-depends: base >=4.4 && <4.7
, unordered-containers >= 0.2.3.0
, unix >= 2.6.0.1
, process >= 1.1.0.2
, stm >= 2.4.2
-- Base language which the package is written in.
default-language: Haskell2010
------------------------------------------------
If I comment out the "build-depends" section for the 2nd (agent) target. I am able to build the 1st (myPersonalMain). But if I try to build this as is, I get:
cabal build myPersonalMain
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring agent-0.1.0.0...
cabal: At least the following dependencies are missing:
base >=4.4 && <4.7
The problem is that 'cabal configure' needs to work and for that, the dependency on the second target (which I don't care about) has to be satisfied. That is a very confusing situation as it seems that the dependencies of the second target are required to build the first. (Ideally, I would like my build to succeed here, as I don't need base<4.7 to build the first target.)
In any case, I have to always have all 'build-depends:' sections satisfy 'cabal configure' to be able to build any single target. That makes a dependency in a tiny unimportant testing package, globally required for me to be able to build any target.
Activity
ezyang commentedon Dec 21, 2015
There are many ways to approach this problem:
ezyang commentedon Jan 13, 2016
See also #1575, which if fixed would fix this problem.
dimitri-xyz commentedon Jan 13, 2016
Making missing dependencies a non-fatal error as suggested or adopting #1575 would definitely solve the problem for my needs.
lingnand commentedon Sep 22, 2017
@ezyang Could you share more details regarding the workaround "create a flag which represents whether or not you want the second executable to build and conditialize your executable stanzas likewise. Then when configuring, Cabal will discover the only satisfying assignment is to disable the second executable, and your code will work."? As far as I know one can't conditionally disable a whole target, so some tricks are needed?
lingnand commentedon Sep 22, 2017
Never mind figured it out. For anyone who's interested - conditionally include the flag
buildable: Falseand exclude thebuild-depends(or True depending on need) to disable a target.