cabal
cabal copied to clipboard
Why cabal-install warns about duplicate config files when CABAL_CONFIG is set?
Warning: Both /home/phadej/.cabal and /home/phadej/.config/cabal/config exist
- ignoring the former.
even I have $CABAL_CONFIG set. The - ignoring the former makes me think that my $CABAL_CONFIG variables is not respected.
I consider this a bug, it misleads the user. I have no idea what happens.
This happens when I use cabal sdist in a project which hadn't been cabal build yet (i.e. no dist-newstyle directory). cabal build doesn't warn.
This non-uniform behavior is definitely a bug.
FWIW, cabal sdist should need to read the config at all, as far as I can tell.
this comes from
https://github.com/haskell/cabal/blob/cd7e7a57a7cc678e3938bdc3310ff32892950fec/cabal-install/src/Distribution/Client/Config.hs#L749-L766
#8877 @athas
and currently blocks our update for GHC 9.14 #11174
My understanding is that the warning is completely insensitive to CABAL_CONFIG, so while the two files it talks about do exist, the message is misleading (none of them are used). I suggest that an easy solution is to modify the logic in loadConfig, where warnOnTwoConfigs is invoked, such that warnOnTwoConfigs is not called when CABAL_CONFIG is set.
Alternatively, the invocation of warnOnTwoConfigs could be moved into getConfigFilePathAndSource and only used in the Default case.
@athas the latter looks a little more plausible to me. But: what about CABAL_DIR? If I set it explicitly, I probably don't want to deal with the warning even if the two configs exist if I explicitly set one of the default locations (like some people do to be on the safe side)? E.g. CABAL_DIR=~/.cabal cabal ....
And then there's an issue with "non-uniform behaviour" as described above?..
We can just check if CABAL_DIR is set before emitting the warning. It will be very ad hoc, but so is everything about the cabal config anyway.
Ugh, getConfigFilePathAndSource does not have access to the Verbosity.
Could you submit a patch along these lines?
Yeah, working on it.