Skip to content

Commit

Permalink
Update GHC environment location (fixes #6565)
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
vituscze committed May 19, 2020
1 parent a4f2082 commit 081130e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cabal-install/Distribution/Client/CmdInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 081130e

Please sign in to comment.