Skip to content

The network-uri flag is incorrect #160

@mniip

Description

@mniip

Background: in 2014, the network package split part of its functionality into a separate network-uri package. The Network.URI module that was available in network <2.6 would no longer be available in network >=2.6, and instead would have to be obtained from network-uri >=2.6. To support this transition, a package that depends on Network.URI and wants to support old and new versions alike has to implement a cabal flag that ensures that either network <2.6 is in use, or network >=2.6, network-uri >=2.6 is in use.

However the literal encoding of this alternative as seen here:

HTTP/HTTP.cabal

Lines 139 to 142 in d1fddc5

if flag(network-uri)
Build-depends: network-uri == 2.6.*, network >= 2.6
else
Build-depends: network < 2.6

is insufficient. The real problem comes from having both network <2.6 and network-uri >=2.6 in the cabal build plan, and it's possible for this to happen if a package depends on HTTP and network-uri.

Said package might not support pre-split network <2.6, but it has no say in whether it's selected because it doesn't directly depend on network, only transitively via HTTP. This is to say that it's HTTP's job to prevent this from happening.

An example of this happens with cabal-install:

$ cabal install cabal-install-3.8.1.0 --with-compiler ghc-9.2.8 --constraint 'network ==2.5.0.0' --constraint 'network-uri ==2.6.4.2'
...
src/Distribution/Client/HttpUtils.hs:802:19: error:
    • Couldn't match type ‘network-2.5.0.0:Network.URI.URI’ with ‘URI’
      NB: ‘URI’
            is defined in ‘Network.URI’ in package ‘network-uri-2.6.4.2’
          ‘network-2.5.0.0:Network.URI.URI’
            is defined in ‘Network.URI’ in package ‘network-2.5.0.0’

To mitigate this (can't quite say "in anticipation of this"), a dummy network-uri-2.5.0.0 version was created: it contains no modules, and acts as a thing you can depend on to prevent >=2.6 versions of network-uri to be included in the plan. Its documentation also suggests the correct flag setup: https://hackage.haskell.org/package/network-uri

  if flag(network-uri)
    build-depends: network-uri >= 2.6, network >= 2.6
  else
    build-depends: network-uri < 2.6, network < 2.6

This problem affects HTTP >=4000.2.16.1 && <=4000.4.1, it was introduced all the way back in #73. Normally hackage revisions would be used to retroactively change dependency constraints, but in case of flags I'm not sure what can be done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions