Skip to content

warnOnTwoConfigs is overzealous on Windows #9277

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

Closed
Bodigrim opened this issue Sep 20, 2023 · 2 comments · Fixed by #9278
Closed

warnOnTwoConfigs is overzealous on Windows #9277

Bodigrim opened this issue Sep 20, 2023 · 2 comments · Fixed by #9278
Labels
cabal-install: other platform: windows re: warnings Concerning warnings printed by cabal re: xdg Concerning the XDG directory structure regression in 3.10 regression on master Regression that is unreleased and needs to be fixed before release type: bug

Comments

@Bodigrim
Copy link
Collaborator

-- | Issue a warning if both @$XDG_CONFIG_HOME/cabal/config@ and
-- @~/.cabal@ exists.
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)."

This is wrong on Windows:

  • getAppUserDataDirectory "cabal" returns C:/Users/<user>/AppData/Roaming/cabal.
  • getXdgDirectory XdgConfig ("cabal" </> "config"), unless XDG environment variables are set (and they are not by default), returns C:/Users/<user>/AppData/Roaming/cabal/config, in the very same folder.

Thus both paths exist and everyone is shown a very confusing warning:

Both C:/Users/<user>/AppData/Roaming/cabal 
and C:/Users/<user>/AppData/Roaming/cabal/config exist - ignoring the former.
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)."

I cannot remove one of them, they are the same location.

This is easy to fix, but I'm unpleasantly surprised that I'm the first person to test Cabal HEAD on Windows. If I may suggest, it would be nice to review that XDG business works outside of Linux paradise.

@fgaz
Copy link
Member

fgaz commented Sep 22, 2023

Looks like this also affects 3.10 :-/ #8971

@fgaz fgaz added regression on master Regression that is unreleased and needs to be fixed before release re: warnings Concerning warnings printed by cabal labels Sep 22, 2023
@Mikolaj
Copy link
Member

Mikolaj commented Sep 22, 2023

This is easy to fix, but I'm unpleasantly surprised that I'm the first person to test Cabal HEAD on Windows. If I may suggest, it would be nice to review that XDG business works outside of Linux paradise.

Yes, we are short on the precious resource of Windows developers and testers. We'll ask especially for WIndows testing once we announce unofficial 3.10.2.0 alpha binaries.

@mergify mergify bot closed this as completed in #9278 Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: other platform: windows re: warnings Concerning warnings printed by cabal re: xdg Concerning the XDG directory structure regression in 3.10 regression on master Regression that is unreleased and needs to be fixed before release type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants