Ticket #742 (closed defect: fixed)

Opened 3 years ago

Last modified 18 months ago

build-depends are unexpectedly global prior to Cabal-1.8 (needs documenting)

Reported by: benmachine Owned by:
Priority: normal Milestone:
Component: Cabal library Version: HEAD
Severity: normal Keywords:
Cc: Difficulty: unknown
GHC Version: Platform:

Description

When I have two executable sections, it seems that the build-depends of one are used in the other. For example, the following:

state.cabal

Cabal-Version: >= 1.2

Name:       state
Version:    0.1
Build-type: Simple

Executable state-tf
  Main-is: Main.hs
  Build-depends: base, transformers, monads-tf

Executable state-mtl
  Main-is: Main.hs
  Build-depends: base, mtl

Main.hs

module Main where

import Control.Monad.State

main = print $ runState (put ()) undefined

fails to compile:

Preprocessing executables for state-0.1...
Building state-0.1...

Main.hs:3:7:
    Ambiguous module name `Control.Monad.State':
      it was found in multiple packages: monads-tf-0.1.0.0 mtl-1.1.1.0

If this is intended (which I doubt) it's at least confusing.

Attachments

doc.patch Download (88.3 KB) - added by benmachine 3 years ago.
documentation additions

Change History

Changed 3 years ago by duncan

  • summary changed from build-depends in Executable sections are unexpectedly global to build-depends are unexpectedly global prior to Cabal-1.8 (needs documenting)

Yes this was the old behaviour and it was not intentional. Because changing the behaviour would have broken old packages we made the change so that it only affects packages that declare themselves to follow a recent version of the Cabal spec, that is if you write:

cabal-version: >=1.8

then you'll get the new sensible behaviour.

I'm not sure that this is actually documented anywhere. Would you like to send in a patch for the user guide? It's in the Cabal repo in simple markdown format.

Changed 3 years ago by benmachine

documentation additions

Changed 3 years ago by benmachine

I darcs sent a patch but I've never really used darcs send before so I'm not really sure if it worked - I've attached it here as well just in case.

I couldn't work out how to build the docs from the markdown source - they are built from an xml file, which I assume is generated from the markdown, but I couldn't work out the regeneration command. I don't think I'm likely to have broken anything, though.

Changed 3 years ago by duncan

  • status changed from new to closed
  • resolution set to fixed

Applied thanks! I also added some updates of my own to the doc text about the cabal-version.

Changed 18 months ago by elga

Note: See TracTickets for help on using tickets.