-
Notifications
You must be signed in to change notification settings - Fork 711
Cannot override --flags= on command line #4452
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
Comments
|
Makes sense. |
Hi everybody. I have made the change to
as shown in the description. Could anyone point me to where I am going wrong? EDIT: to be more specific. I run |
Hi @colinwahl! @krpopo has been looking at this ticket and discovered that there are actually two buggy call sites. With the change I suggested, |
I don't plan to work on this any more |
@VetoPlayer is looking into this one. |
This is to fix issue haskell#4452.
This is to fix issue haskell#4452.
This is to fix issue haskell#4452.
This is to fix issue haskell#4452.
This is to fix issue haskell#4452.
This is to fix issue haskell#4452.
Fixed by #4940. |
Uh oh!
There was an error while loading. Please reload this page.
WARNING There are updates to this ticket, please read the discussion.
Summary. It's common that the last given value of a flag "wins".
I expected the last line to have set
dev=False
. According to the documentation it should bedev=False
.Explanation (by @ezyang).
Cabal has quite flexible handling of duplicate instances of arguments when doing command line handling. It does so using monoids, which are types which have a binary "combining" operation defined for them. ConfigFlags, defined in
Cabal/Distribution/Simple/Setup.hs
, defines the monoid instance for ALL configuration flags, by applying the monoid for each individual field.Flag assignment is recorded in
configConfigurationsFlags
, which is defined to be a list. The monoid instance for lists is append. This means that when a flag shows up twice, the lists get appended together; with the example above, you end up with[("dev", True), ("dev", False)]
.The bug is in this code
Distribution/PackageDescription/Configuration.hs
:Here,
userflags
is the list of flag assignments, possibly with duplicates, in the order they occurred on the command line. The problem is thatlookup
will pick up the FIRST entry, rather than the LAST entry. A better and more efficient strategy is to build a map, preferring the last entry, and then do a lookup on this map. If you do that, the bug will be fixed!What you will learn. How to build Cabal. How to convert a key-value list of items into a map, and then do a lookup on it. How to do command line arguments with Monoids. How to look through the verbose output of cabal configure to find the info you need.
Going further. This bug doesn't really require a test, but if you want to add one, it should be fairly easy. Follow the instructions in https://github.com/haskell/cabal/tree/master/cabal-testsuite
The text was updated successfully, but these errors were encountered: