Skip to content

Commit

Permalink
Merge pull request #9278 from haskell/t9277/fix-warnOnTwoConfigs-on-W…
Browse files Browse the repository at this point in the history
…indows

Fix overzealous warnOnTwoConfigs
  • Loading branch information
mergify[bot] authored Sep 22, 2023
2 parents bf6653e + 41d7946 commit b639bfa
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cabal-install/src/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -731,17 +731,19 @@ initialSavedConfig = do
warnOnTwoConfigs :: Verbosity -> IO ()
warnOnTwoConfigs verbosity = do
defaultDir <- getAppUserDataDirectory "cabal"
dotCabalExists <- doesDirectoryExist defaultDir
xdgCfg <- getXdgDirectory XdgConfig ("cabal" </> "config")
xdgCfgExists <- doesFileExist xdgCfg
when (dotCabalExists && xdgCfgExists) $
warn verbosity $
"Both "
<> defaultDir
<> " and "
<> xdgCfg
<> " exist - ignoring the former.\n"
<> "It is advisable to remove one of them. In that case, we will use the remaining one by default (unless '$CABAL_DIR' is explicitly set)."
xdgCfgDir <- getXdgDirectory XdgConfig "cabal"
when (defaultDir /= xdgCfgDir) $ do
dotCabalExists <- doesDirectoryExist defaultDir
let xdgCfg = xdgCfgDir </> "config"
xdgCfgExists <- doesFileExist xdgCfg
when (dotCabalExists && xdgCfgExists) $
warn verbosity $
"Both "
<> defaultDir
<> " and "
<> xdgCfg
<> " exist - ignoring the former.\n"
<> "It is advisable to remove one of them. In that case, we will use the remaining one by default (unless '$CABAL_DIR' is explicitly set)."

-- | If @CABAL\_DIR@ is set, return @Just@ its value. Otherwise, if
-- @~/.cabal@ exists and @$XDG_CONFIG_HOME/cabal/config@ does not
Expand Down

0 comments on commit b639bfa

Please sign in to comment.