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

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

Closed
andreasabel opened this issue Nov 8, 2021 · 4 comments
Labels
documentation re: build-tool Concerning `build-tools` and `build-tool-depends` re: constraint Concerning the constraint syntax, field, and command-line option

Comments

@andreasabel
Copy link
Member

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.)

@andreasabel andreasabel added re: build-tool Concerning `build-tools` and `build-tool-depends` re: constraint Concerning the constraint syntax, field, and command-line option labels Nov 8, 2021
@Mikolaj
Copy link
Member

Mikolaj commented Nov 8, 2021

Possibly distantly related: #7787.

Edit: oh, you've already seen it.

@phadej
Copy link
Collaborator

phadej commented Nov 8, 2021

% cabal install -w ghc-7.10.3 --program-suffix=-2.8 --constraint='any.alex<3.1.4' BNFC-2.8
Warning: The package list for 'hackage.haskell.org' is 23 days old.
Run 'cabal update' to get the latest list of available packages.
Warning: The package list for 'hackage.haskell.org' is 23 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: BNFC (user goal)
[__0] rejecting: BNFC-2.9.3, BNFC-2.9.2, BNFC-2.9.1, BNFC-2.9.0, BNFC-2.8.4,
BNFC-2.8.3, BNFC-2.8.2, BNFC-2.8.1 (constraint from user target requires
==2.8)
[__0] trying: BNFC-2.8
[__1] next goal: BNFC:alex:exe.alex (dependency of BNFC)
[__1] rejecting: BNFC:alex:exe.alex-3.2.6, BNFC:alex:exe.alex-3.2.5,
BNFC:alex:exe.alex-3.2.4, BNFC:alex:exe.alex-3.2.3, BNFC:alex:exe.alex-3.2.2,
BNFC:alex:exe.alex-3.2.1, BNFC:alex:exe.alex-3.2.0, BNFC:alex:exe.alex-3.1.7,
BNFC:alex:exe.alex-3.1.6, BNFC:alex:exe.alex-3.1.5, BNFC:alex:exe.alex-3.1.4
(constraint from command line flag requires <3.1.4)
[__1] trying: BNFC:alex:exe.alex-3.1.3
[__2] next goal: BNFC:alex:exe.base (dependency of BNFC:alex:exe.alex
+/-small_base)
[__2] rejecting:
BNFC:alex:exe.base-4.8.2.0/installed-0d6d1084fbc041e1cded9228e80e264d
(conflict: BNFC:alex:exe.alex +/-small_base => BNFC:alex:exe.base>=1.0 &&
<4.8)
[__2] rejecting: BNFC:alex:exe.base-4.15.0.0, BNFC:alex:exe.base-4.14.3.0,
BNFC:alex:exe.base-4.14.2.0, BNFC:alex:exe.base-4.14.1.0,
BNFC:alex:exe.base-4.14.0.0, BNFC:alex:exe.base-4.13.0.0,
BNFC:alex:exe.base-4.12.0.0, BNFC:alex:exe.base-4.11.1.0,
BNFC:alex:exe.base-4.11.0.0, BNFC:alex:exe.base-4.10.1.0,
BNFC:alex:exe.base-4.10.0.0, BNFC:alex:exe.base-4.9.1.0,
BNFC:alex:exe.base-4.9.0.0, BNFC:alex:exe.base-4.8.2.0,
BNFC:alex:exe.base-4.8.1.0, BNFC:alex:exe.base-4.8.0.0,
BNFC:alex:exe.base-4.7.0.2, BNFC:alex:exe.base-4.7.0.1,
BNFC:alex:exe.base-4.7.0.0, BNFC:alex:exe.base-4.6.0.1,
BNFC:alex:exe.base-4.6.0.0, BNFC:alex:exe.base-4.5.1.0,
BNFC:alex:exe.base-4.5.0.0, BNFC:alex:exe.base-4.4.1.0,
BNFC:alex:exe.base-4.4.0.0, BNFC:alex:exe.base-4.3.1.0,
BNFC:alex:exe.base-4.3.0.0, BNFC:alex:exe.base-4.2.0.2,
BNFC:alex:exe.base-4.2.0.1, BNFC:alex:exe.base-4.2.0.0,
BNFC:alex:exe.base-4.1.0.0, BNFC:alex:exe.base-4.0.0.0,
BNFC:alex:exe.base-3.0.3.2, BNFC:alex:exe.base-3.0.3.1 (constraint from
non-upgradeable package requires installed instance)
[__2] fail (backjumping, conflict set: BNFC:alex:exe.alex, BNFC:alex:exe.base)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: BNFC:alex:exe.base,
BNFC:alex:exe.alex, base, BNFC
Try running with --minimize-conflict-set to improve the error message.

which seems correct, as alex-3.1.3 and older have base <4.8 bound.

TL:DR --constraint="any.alex <version range>"

@andreasabel
Copy link
Member Author

Thanks @phadej, this worked! (Although I ran into the more severe problem that GHC <= 7.6 doesn't work on macOS due to SIP.)

TODO left: document constraint syntax better.

@jneira jneira changed the title Can I constrain a build-tool on the command line? Document constraint syntax better (was Can I constrain a build-tool on the command line?) May 14, 2022
@jneira
Copy link
Member

jneira commented May 14, 2022

last actionable would be duplicate of #5373

@jneira jneira closed this as completed May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation re: build-tool Concerning `build-tools` and `build-tool-depends` re: constraint Concerning the constraint syntax, field, and command-line option
Projects
None yet
Development

No branches or pull requests

4 participants