From 692ba50962806a77f5c612a8c9b2a9aa5733df0d Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Wed, 31 Aug 2016 21:59:28 -0500 Subject: [PATCH] Respect GHC_PACKAGE_PATH Fixes #3728. Fixes #2711. --- Cabal/Distribution/Simple/GHC.hs | 13 ++++++------- Cabal/Distribution/Simple/GHCJS.hs | 14 +++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index af2309315b3..a2801958c3e 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -86,6 +86,7 @@ import Distribution.Text import Distribution.Utils.NubList import Language.Haskell.Extension +import Distribution.Compat.Environment ( lookupEnv ) import qualified Data.Map as Map import Data.Version ( showVersion ) import System.Directory @@ -93,7 +94,7 @@ import System.Directory , canonicalizePath, removeFile ) import System.FilePath ( (), (<.>), takeExtension , takeDirectory, replaceExtension - , isRelative ) + , isRelative, searchPathSeparator ) import qualified System.Info -- ----------------------------------------------------------------------------- @@ -283,9 +284,11 @@ getInstalledPackages :: Verbosity -> Compiler -> PackageDBStack -> ProgramConfiguration -> IO InstalledPackageIndex getInstalledPackages verbosity comp packagedbs conf = do - checkPackageDbEnvVar checkPackageDbStack comp packagedbs - pkgss <- getInstalledPackages' verbosity packagedbs conf + envPackageDBs <- maybe [] + (map SpecificPackageDB . unintersperse searchPathSeparator) + <$> lookupEnv "GHC_PACKAGE_PATH" + pkgss <- getInstalledPackages' verbosity (envPackageDBs ++ packagedbs) conf index <- toPackageIndex verbosity pkgss conf return $! hackRtsPackage index @@ -351,10 +354,6 @@ getUserPackageDB _verbosity ghcProg (Platform arch os) = do | otherwise = "package.conf" Just ghcVersion = programVersion ghcProg -checkPackageDbEnvVar :: IO () -checkPackageDbEnvVar = - Internal.checkPackageDbEnvVar "GHC" "GHC_PACKAGE_PATH" - checkPackageDbStack :: Compiler -> PackageDBStack -> IO () checkPackageDbStack comp = if flagPackageConf implInfo then checkPackageDbStackPre76 diff --git a/Cabal/Distribution/Simple/GHCJS.hs b/Cabal/Distribution/Simple/GHCJS.hs index f59fb6b9cb1..e0723feb85f 100644 --- a/Cabal/Distribution/Simple/GHCJS.hs +++ b/Cabal/Distribution/Simple/GHCJS.hs @@ -48,7 +48,9 @@ import Language.Haskell.Extension import qualified Data.Map as Map import System.Directory ( doesFileExist ) import System.FilePath ( (), (<.>), takeExtension - , takeDirectory, replaceExtension ) + , takeDirectory, replaceExtension + , searchPathSeparator ) +import Distribution.Compat.Environment ( lookupEnv ) configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration @@ -187,9 +189,11 @@ getPackageDBContents verbosity packagedb conf = do getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO InstalledPackageIndex getInstalledPackages verbosity packagedbs conf = do - checkPackageDbEnvVar checkPackageDbStack packagedbs - pkgss <- getInstalledPackages' verbosity packagedbs conf + envPackageDBs <- maybe [] + (map SpecificPackageDB . unintersperse searchPathSeparator) + <$> lookupEnv "GHCJS_PACKAGE_PATH" + pkgss <- getInstalledPackages' verbosity (envPackageDBs ++ packagedbs) conf index <- toPackageIndex verbosity pkgss conf return $! index @@ -209,10 +213,6 @@ toPackageIndex verbosity pkgss conf = do where Just ghcjsProg = lookupProgram ghcjsProgram conf -checkPackageDbEnvVar :: IO () -checkPackageDbEnvVar = - Internal.checkPackageDbEnvVar "GHCJS" "GHCJS_PACKAGE_PATH" - checkPackageDbStack :: PackageDBStack -> IO () checkPackageDbStack (GlobalPackageDB:rest) | GlobalPackageDB `notElem` rest = return ()