Skip to content

Commit

Permalink
Ignore global database when copying precompiled packages #1146
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Oct 12, 2015
1 parent 5d335ab commit 6b8fd22
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Bug fixes:
* Add `explicit-setup-deps` option [#1110](https://github.com/commercialhaskell/stack/issues/1110), and change the default to the old behavior of using any package in the global and snapshot database [#1025](https://github.com/commercialhaskell/stack/issues/1025)
* Precompiled cache checks full package IDs on Cabal < 1.22 [#1103](https://github.com/commercialhaskell/stack/issues/1103)
* Pass -package-id to ghci [#867](https://github.com/commercialhaskell/stack/issues/867)
* Ignore global packages when copying precompiled packages [#1146](https://github.com/commercialhaskell/stack/issues/1146)

## 0.1.5.0

Expand Down
15 changes: 11 additions & 4 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,18 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in
announceTask task "copying precompiled package"
forM_ mlib $ \libpath -> do
menv <- getMinimalEnvOverride
withMVar eeInstallLock $ \() ->
readProcessNull Nothing menv "ghc-pkg"
withMVar eeInstallLock $ \() -> do
-- We want to ignore the global and user databases.
-- Unfortunately, ghc-pkg doesn't take such arguments on the
-- command line. Instead, we'll set GHC_PACKAGE_PATH. See:
-- https://github.com/commercialhaskell/stack/issues/1146

menv' <- modifyEnvOverride menv
$ Map.insert
"GHC_PACKAGE_PATH"
(T.pack $ toFilePath $ bcoSnapDB eeBaseConfigOpts)
readProcessNull Nothing menv' "ghc-pkg"
[ "register"
, "--no-user-package-db"
, "--package-db=" ++ toFilePath (bcoSnapDB eeBaseConfigOpts)
, "--force"
, libpath
]
Expand Down
12 changes: 12 additions & 0 deletions src/System/Process/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module System.Process.Read
,EnvOverride(..)
,unEnvOverride
,mkEnvOverride
,modifyEnvOverride
,envHelper
,doesExecutableExist
,findExecutable
Expand Down Expand Up @@ -77,6 +78,7 @@ data EnvOverride = EnvOverride
, eoPath :: [FilePath]
, eoExeCache :: IORef (Map FilePath (Either ReadProcessException (Path Abs File)))
, eoExeExtension :: String
, eoPlatform :: Platform
}

-- | Get the environment variables from @EnvOverride@
Expand All @@ -87,6 +89,15 @@ unEnvOverride = eoTextMap
envSearchPath :: EnvOverride -> [FilePath]
envSearchPath = eoPath

-- | Modify an EnvOverride
modifyEnvOverride :: MonadIO m
=> EnvOverride
-> (Map Text Text -> Map Text Text)
-> m EnvOverride
modifyEnvOverride eo f = mkEnvOverride
(eoPlatform eo)
(f $ eoTextMap eo)

-- | Create a new @EnvOverride@
mkEnvOverride :: MonadIO m
=> Platform
Expand All @@ -100,6 +111,7 @@ mkEnvOverride platform tm' = do
, eoPath = maybe [] (FP.splitSearchPath . T.unpack) (Map.lookup "PATH" tm)
, eoExeCache = ref
, eoExeExtension = if isWindows then ".exe" else ""
, eoPlatform = platform
}
where
-- Fix case insensitivity of the PATH environment variable on Windows.
Expand Down

0 comments on commit 6b8fd22

Please sign in to comment.