Skip to content

Fix overzealous warnOnTwoConfigs #9278

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

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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