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

cabal configure making dependencies global #2725

Open
dimitri-xyz opened this issue Jul 18, 2015 · 5 comments
Open

cabal configure making dependencies global #2725

dimitri-xyz opened this issue Jul 18, 2015 · 5 comments

Comments

@dimitri-xyz
Copy link

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.

@ezyang
Copy link
Contributor

ezyang commented Dec 21, 2015

There are many ways to approach this problem:

  • Here is a 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.
  • At configure time (in Cabal library), Cabal attempts to configure ALL components, regardless if you actually plan to build them. There is literally no way to ask configure to only configure some componets. Specify components when configuring, not building #2802 requests the ability to pick components to be configured at configure time; once you have this, then you would be fine.
  • Talking to @dcoutts, he has suggested that we should continue to configure all components, but make it non-fatal if some components missed dependencies (in that case, you just wouldn't be able to build them.)

@ezyang ezyang added the ezyang label Jan 13, 2016
@ezyang
Copy link
Contributor

ezyang commented Jan 13, 2016

See also #1575, which if fixed would fix this problem.

@dimitri-xyz
Copy link
Author

Making missing dependencies a non-fatal error as suggested or adopting #1575 would definitely solve the problem for my needs.

@lingnand
Copy link

@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
Copy link

Never mind figured it out. For anyone who's interested - conditionally include the flag buildable: False and exclude the build-depends (or True depending on need) to disable a target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants