You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Misspelled user-flags (-f) are silently ignored #7813
This is tricky. What if a version of package doesn't have (an automatic) flag. Should it be omitted by a solver? What if there is a package in the transitive dependency tree which uses licence-report spelling?
I think you ask for a feature, which is not yet described precisely.
From there, I could not understand the concept of flags completely.
What if there is a package in the transitive dependency tree which uses licence-report spelling?
My natural assumption is that if I pass -f{+|-}foo then this flag foo is set for the main package that is the target of the build. I also assume that if I want to pass a flag to a dependency, I need to qualify it accordingly. Is this assumption correct?
Under the correctness of my assumption, it would not matter if some dependency accepts the miss-spelled licence-report as I would have to qualify it for that dependency to pick it up.
What if a version of package doesn't have (an automatic) flag [?]
This is more tricky. So the set of valid flags for a package depends on the version of that package. We can be conservative and take the union of all flags that have existed and exist now for this package. This would still allow me to catch most misspellings.
Nonwithstanding the exact workings of flags, this improvement should always work: If a flag passed by the user is never looked at during configuration, a warning is emitted.
Warning: flag '{+|-}foo' did not affect this build.
(This is a bit comparable to a unused-import-warning in a compiler.)
However, I would think scoping of flags can be exploited for a firmer error report.
My natural assumption is that if I pass -f{+|-}foo then this flag foo is set for the main package that is the target of the build. I also assume that if I want to pass a flag to a dependency, I need to qualify it accordingly. Is this assumption correct?
Hmm. Seems so that -f applies only to local packages. So your assumption is correct.
But this drives me nuts as --ghc-options applies to all packages. This is inconsistent, so I don't have any intuition about cabal-install command line interface anymore.
I have another example but this time for a flag no longer used by a package. I'd like to be warned about obsolete flags.
I tried to build haskell/cabal@976f86/cabal.project with stack (after generating the equivalent stack.yaml project) and it warned that these doesn't have an assoc flag. Browsing hackage/these, I see this package used to have an assoc flag in assoc >=1 && <1.2 versions but not in assoc ==1.2.
Error: [S-8664]
Invalid flag specification:
* Package these does not define the following flags
(specified in the project-level configuration (e.g. stack.yaml)): assoc.
No flags are defined by package these.
make: *** [updo/Makefile:100: stack.yaml.lock] Error 1
@philderbeast your example illustrates why miss-spelling a flag should never be an error. these-1.2 removed the assoc flag, as there were no use for it. Such change should not break builds. Having a warning is fine.
Also -f semantics in cabal are bad (fine for ./Setup, bad for cabal-install). They apply to all packages. If it were package specific, i.e. -fcabal-plan:license-report, then there are more options:
warn if not available
or/and restrict version ranges to packages with the flag
In stack flag specification is per-package. (In cabal we can also, with constraints or in cabal.projectpackage sections, but AFAIK we cannot on the command line).
FWIW, this is another example where I think that cabal-install CLI interface should be completely separate from ./Setup ones. Trying to have the same CLI API, but tweak it from exactly-one-package to a project wide just causes huge impedance mismatches. stack is definitely better in that regard, as their CLI interface started from scratch. v2-build missed an opportunity.
💯 agree with @phadej. I am afraid separating the CLI will take some work but perhaps there's a quicker way to parse per-package flags?
There is also the issue that project config goes through the legay SavedConfig so I won't hold my breath; but I'm happy to advice if anyone wants to take on this.
To be clear, one can specify flags per-package on the command line, through the Setup.hs interface even, by passing flag settings via constraints rather than -f
Activity
phadej commentedon Nov 13, 2021
This is tricky. What if a version of package doesn't have (an automatic) flag. Should it be omitted by a solver? What if there is a package in the transitive dependency tree which uses
licence-reportspelling?I think you ask for a feature, which is not yet described precisely.
andreasabel commentedon Nov 19, 2021
The documentation is a bit scarce, I found these pages:
From there, I could not understand the concept of flags completely.
My natural assumption is that if I pass
-f{+|-}foothen this flagfoois set for the main package that is the target of the build. I also assume that if I want to pass a flag to a dependency, I need to qualify it accordingly. Is this assumption correct?Under the correctness of my assumption, it would not matter if some dependency accepts the miss-spelled
licence-reportas I would have to qualify it for that dependency to pick it up.This is more tricky. So the set of valid flags for a package depends on the version of that package. We can be conservative and take the union of all flags that have existed and exist now for this package. This would still allow me to catch most misspellings.
Nonwithstanding the exact workings of flags, this improvement should always work:
If a flag passed by the user is never looked at during configuration, a warning is emitted.
(This is a bit comparable to a unused-import-warning in a compiler.)
However, I would think scoping of flags can be exploited for a firmer error report.
phadej commentedon Nov 19, 2021
Hmm. Seems so that
-fapplies only to local packages. So your assumption is correct.But this drives me nuts as
--ghc-optionsapplies to all packages. This is inconsistent, so I don't have any intuition aboutcabal-installcommand line interface anymore.ulysses4ever commentedon May 30, 2022
Not anymore: #3883 (comment)
philderbeast commentedon Nov 12, 2023
I have another example but this time for a flag no longer used by a package. I'd like to be warned about obsolete flags.
I tried to build haskell/cabal@976f86/cabal.project with stack (after generating the equivalent
stack.yamlproject) and it warned thatthesedoesn't have anassocflag. Browsing hackage/these, I see this package used to have anassocflag inassoc >=1 && <1.2versions but not inassoc ==1.2.If I do
cabal freezeI see:For comparison, here's stack's full warning:
phadej commentedon Nov 12, 2023
@philderbeast your example illustrates why miss-spelling a flag should never be an error.
these-1.2removed theassocflag, as there were no use for it. Such change should not break builds. Having a warning is fine.Also
-fsemantics incabalare bad (fine for./Setup, bad forcabal-install). They apply to all packages. If it were package specific, i.e.-fcabal-plan:license-report, then there are more options:In
stackflag specification is per-package. (Incabalwe can also, withconstraintsor incabal.projectpackagesections, but AFAIK we cannot on the command line).FWIW, this is another example where I think that
cabal-installCLI interface should be completely separate from./Setupones. Trying to have the same CLI API, but tweak it from exactly-one-package to a project wide just causes huge impedance mismatches.stackis definitely better in that regard, as their CLI interface started from scratch.v2-buildmissed an opportunity.andreabedini commentedon Nov 13, 2023
💯 agree with @phadej. I am afraid separating the CLI will take some work but perhaps there's a quicker way to parse per-package flags?
There is also the issue that project config goes through the legay
SavedConfigso I won't hold my breath; but I'm happy to advice if anyone wants to take on this.gbaz commentedon Nov 17, 2023
To be clear, one can specify flags per-package on the command line, through the Setup.hs interface even, by passing flag settings via
constraintsrather than-fhttps://cabal.readthedocs.io/en/stable/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-constraint