Skip to content

Commit 41d7946

Browse files
BodigrimMikolaj
authored andcommitted
Fix overzelous warnOnTwoConfigs
1 parent bf6653e commit 41d7946

File tree

1 file changed

+13
-11
lines changed
  • cabal-install/src/Distribution/Client

1 file changed

+13
-11
lines changed

cabal-install/src/Distribution/Client/Config.hs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -731,17 +731,19 @@ initialSavedConfig = do
731731
warnOnTwoConfigs :: Verbosity -> IO ()
732732
warnOnTwoConfigs verbosity = do
733733
defaultDir <- getAppUserDataDirectory "cabal"
734-
dotCabalExists <- doesDirectoryExist defaultDir
735-
xdgCfg <- getXdgDirectory XdgConfig ("cabal" </> "config")
736-
xdgCfgExists <- doesFileExist xdgCfg
737-
when (dotCabalExists && xdgCfgExists) $
738-
warn verbosity $
739-
"Both "
740-
<> defaultDir
741-
<> " and "
742-
<> xdgCfg
743-
<> " exist - ignoring the former.\n"
744-
<> "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)."
734+
xdgCfgDir <- getXdgDirectory XdgConfig "cabal"
735+
when (defaultDir /= xdgCfgDir) $ do
736+
dotCabalExists <- doesDirectoryExist defaultDir
737+
let xdgCfg = xdgCfgDir </> "config"
738+
xdgCfgExists <- doesFileExist xdgCfg
739+
when (dotCabalExists && xdgCfgExists) $
740+
warn verbosity $
741+
"Both "
742+
<> defaultDir
743+
<> " and "
744+
<> xdgCfg
745+
<> " exist - ignoring the former.\n"
746+
<> "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)."
745747

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

0 commit comments

Comments
 (0)