Commit 081130e6 authored by Vít Šefl's avatar Vít Šefl

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/
parent a4f20826
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment