From 081130e6f7184e4746b7bb0252f83c30335066a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20=C5=A0efl?= Date: Tue, 19 May 2020 14:13:48 +0200 Subject: [PATCH] Update GHC environment location (fixes #6565) Previously, cabal-install assumed that the default GHC environments are located in $HOME/.ghc/ on all systems. However, on Windows, GHC looks for environments in %APPDATA%/ghc/ --- cabal-install/Distribution/Client/CmdInstall.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cabal-install/Distribution/Client/CmdInstall.hs b/cabal-install/Distribution/Client/CmdInstall.hs index 2a09baa26..2377ffa21 100644 --- a/cabal-install/Distribution/Client/CmdInstall.hs +++ b/cabal-install/Distribution/Client/CmdInstall.hs @@ -146,7 +146,7 @@ import Distribution.Utils.NubList ( fromNubList ) import Network.URI (URI) import System.Directory - ( getHomeDirectory, doesFileExist, createDirectoryIfMissing + ( getAppUserDataDirectory, doesFileExist, createDirectoryIfMissing , getTemporaryDirectory, makeAbsolute, doesDirectoryExist , removeFile, removeDirectory, copyFile ) import System.FilePath @@ -850,13 +850,13 @@ entriesForLibraryComponents = Map.foldrWithKey' (\k v -> mappend (go k v)) [] -- | Gets the file file path to the request environment file. getEnvFile :: ClientInstallFlags -> Platform -> Version -> IO FilePath getEnvFile clientInstallFlags platform compilerVersion = do - home <- getHomeDirectory + appData <- getAppUserDataDirectory "ghc" case flagToMaybe (cinstEnvironmentPath clientInstallFlags) of Just spec -- Is spec a bare word without any "pathy" content, then it refers to -- a named global environment. | takeBaseName spec == spec -> - return (getGlobalEnv home platform compilerVersion spec) + return (getGlobalEnv appData platform compilerVersion spec) | otherwise -> do spec' <- makeAbsolute spec isDir <- doesDirectoryExist spec' @@ -867,7 +867,7 @@ getEnvFile clientInstallFlags platform compilerVersion = do -- Otherwise, treat it like a literal file path. else return spec' Nothing -> - return (getGlobalEnv home platform compilerVersion "default") + return (getGlobalEnv appData platform compilerVersion "default") -- | Returns the list of @GhcEnvFilePackageIj@ values already existing in the -- environment being operated on. @@ -891,8 +891,8 @@ getExistingEnvEntries verbosity compilerFlavor supportsPkgEnvFiles envFile = do -- -- TODO(m-renaud): Create PkgEnvName newtype wrapper. getGlobalEnv :: FilePath -> Platform -> Version -> String -> FilePath -getGlobalEnv home platform compilerVersion name = - home ".ghc" ghcPlatformAndVersionString platform compilerVersion +getGlobalEnv appData platform compilerVersion name = + appData ghcPlatformAndVersionString platform compilerVersion "environments" name -- | Constructs the path to a local GHC environment file. -- GitLab