Skip to content

cabal install does not reinstall when user flags (-f) change  #7814

Closed

Description

@andreasabel

cabal install does not reinstall when user flags (-f) change. In the wild:

$ cabal install -w ghc-9.0.1  cabal-plan
...((Success))...

$ cabal-plan license-report fix-whitespace 
ERROR: `cabal-plan license-report` sub-command not available! Please recompile/reinstall `cabal-plan` with the `license-report` Cabal flag activated.

Oh, forgot the -f license-report flag. Ok, then:

$ cabal install -w ghc-9.0.1 -f license-report cabal-plan
Resolving dependencies...
Build profile: -w ghc-9.0.1 -O1
In order, the following will be built (use -v for more details):
 - cabal-plan-0.7.2.1 (lib) (requires build)
Configuring library for cabal-plan-0.7.2.1..
Preprocessing library for cabal-plan-0.7.2.1..
Building library for cabal-plan-0.7.2.1..
[1 of 1] Compiling Cabal.Plan       ( src/Cabal/Plan.hs, dist/build/Cabal/Plan.o, dist/build/Cabal/Plan.dyn_o )
Installing library in /Users/abel/.cabal/store/ghc-9.0.1/incoming/new-14995/Users/abel/.cabal/store/ghc-9.0.1/cbl-pln-0.7.2.1-9877695f/lib
Warning:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: Installation might not be completed as desired! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The command "cabal install [TARGETS]" doesn't expose libraries.
* You might have wanted to add them as dependencies to your package. In this
case add "cabal-plan" to the build-depends field(s) of your package's .cabal
file.
* You might have wanted to add them to a GHC environment. In this case use
"cabal install --lib cabal-plan". The "--lib" flag is provisional: see
https://github.com/haskell/cabal/issues/6481 for more information.

$ cabal-plan license-report fix-whitespace 
ERROR: `cabal-plan license-report` sub-command not available! Please recompile/reinstall `cabal-plan` with the `license-report` Cabal flag activated.

Vad fan!

So, cabal install does not reinstall executables if the flags change. Somehow in its subconscious mind, cabal notices that maybe it did not satisfy the customer fully, and issues a warning, but confuses it with a --lib installation request.

Atm, I do not know how to proceed, because --reinstall is anyway ignored:

$ cabal install -w ghc-9.0.1 -f license-report --reinstall cabal-plan
Resolving dependencies...
Up to date
Warning:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: Installation might not be completed as desired! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The command "cabal install [TARGETS]" doesn't expose libraries.
...

Activity

  1. added
    re: flag
    on Nov 13, 2021
  2. andreasabel commented on Nov 13, 2021

    @andreasabel
    MemberAuthor

    Thank God for v1-install:

    $ cabal v1-install -w ghc-9.0.1 -f license-report cabal-plan
    
  3. added
    re: v1-install
    on Nov 13, 2021
  4. phadej commented on Nov 13, 2021

    @phadej
    Collaborator

    Vad fan!

    Clear up your language.


    Note there is an (automatic) +exe flag in cabal-plan. If it cannot be (easily) satisfied, it is turned off. Try with -fexe (or --constraint='cabal-plan +exe).

    EDIT: The issue automatic +exe flag tries to solve is that solver wouldn't be restricted by exe-dependencies when cabal-plan is used as a library. There are Cabal issues open about per-component solving.

  5. andreasabel commented on Nov 13, 2021

    @andreasabel
    MemberAuthor

    @phadej: I am sorry, but this is not easily discoverable:
    Screenshot 2021-11-13 at 14 10 51

    There is an exe flag here but this is by default Enabled. So why should I worry about it?
    I am not getting an alert that this flag was automatically disabled, and what the consequences of this automatic choice are.
    I also did not have to supply -fexe when I installed without -f license-report.
    Flag license-report adds a functionality to the executable, so why should adding this flag prevent installation of the executable? This makes no sense to me.

    v1-install does not suffer from this defective behavior (in this case).

    Vad fan!

    Clear up your language.

    I already did, this is what remained.

  6. added
    re: user experience
    and removed on Nov 13, 2021
  7. andreasabel commented on Nov 13, 2021

    @andreasabel
    MemberAuthor

    Following the discussion, this is maybe a cabal-plan issue.

  8. phadej commented on Nov 13, 2021

    @phadej
    Collaborator

    I am sorry, but this is not easily discoverable:

    hackage-server developers hide automatic flags. i don't like the folding myself. haskell/hackage-server#963

    Flag license-report adds a functionality to the executable, so why should adding this flag prevent installation of the executable? This makes no sense to me.

    You answered it yourself: it adds functionality, and for that it adds dependencies (probably Cabal) which forces solver to work harder. It decides to turn off automatic exe flag.


    There are two solutions:

    • fix cabal-install solver to not consider executable components when only library is asked for. This would remove the need for -fexe hack (preferable)
    • split the executable cabal-plan into separate cabal-plan-exe package (not nice).
  9. phadej commented on Nov 13, 2021

    @phadej
    Collaborator

    Another example is yaml package. Which has no-exe flag guarding yaml2json and json2yaml executables.

    Maybe I should flip the exe flag in cabal-plan to by False by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cabal-install: cmd/installre: flagre: user experiencere: v1-install

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions