summaryrefslogtreecommitdiff
path: root/hadrian/src/Environment.hs
blob: ef98bb100bac0cbdbc7379c4e426a269dfe72ea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Environment (setupEnvironment) where

import System.Environment

-- | The build system invokes many external builders whose behaviour is
-- influenced by the environment variables. We need to modify some of them
-- for better robustness of the build system.
setupEnvironment :: IO ()
setupEnvironment = do
    -- Cabal refuses to work when GHC_PACKAGE_PATH is set (e.g. by Stack)
    unsetEnv "GHC_PACKAGE_PATH"

    -- cabal new-exec sets GHC_ENVIRONMENT, it needs to be unset for GHC
    -- invocations to work properly
    unsetEnv "GHC_ENVIRONMENT"

    -- in MinGW if PWD is set to a Windows "C:\\" style path then configure
    -- `pwd` will return the Windows path, and then modifying $PATH will fail.
    -- See https://github.com/snowleopard/hadrian/issues/189 for details.
    unsetEnv "PWD"