Skip to content

Document constraint syntax better (was Can I constrain a build-tool on the command line?) #7804

Closed
@andreasabel

Description

@andreasabel

I am trying

$ cabal install -w ghc-7.10.3 --program-suffix=-2.8 --constraint='alex<3.1.4' BNFC-2.8

The constraint alex<3.1.4 seems to be accepted (no error), but ignored: No attempts to build an alex < 3.1.4, and the generated lexer fails (likely due to a too new version of alex):

[17 of 97] Compiling LexBNF           ( dist/build/bnfc/bnfc-tmp/LexBNF.hs, dist/build/bnfc/bnfc-tmp/LexBNF.o )

src/LexBNF.x:164:38:
    Not in scope: ‘ord’

Trying qualification, like either of

$ cabal install -w ghc-7.10.3 --program-suffix=-2.8 --constraint='alex:alex<3.1.4' BNFC-2.8
$ cabal install -w ghc-7.10.3 --program-suffix=-2.8 --constraint='alex:exe:alex<3.1.4' BNFC-2.8

gives a syntax error:

Error: cabal: invalid argument to option `--constraint': expected a (possibly
qualified) package name followed by a constraint, which is either a version
range, 'installed', 'source', 'test', 'bench', or flags. "<eitherParsec>"
(line 1, column 6):
unexpected ...
expecting "setup."

I found the following in the changelog of 2.0.0.0:

  • Added qualified constraints for setup dependencies. For example, --constraint="setup.bar == 1.0" constrains all setup dependencies on bar, and --constraint="foo:setup.bar == 1.0" constrains foo's setup dependency on bar (part of Constraint syntax is not expressive enough. #3502).
  • Non-qualified constraints, such as --constraint="bar == 1.0", now only apply to top-level dependencies. They don't constrain setup or build-tool dependencies. The new syntax --constraint="any.bar == 1.0" constrains all uses of bar.

But I don't know whether this is the last state of affairs, the documentation is not explicit about it. (See also #7535.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationre: build-toolConcerning `build-tools` and `build-tool-depends`re: constraintConcerning the constraint syntax, field, and command-line option

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions