Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit d1e442b

Browse files
committed
Take in account local cache dir
1 parent da3f777 commit d1e442b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

install/src/Stack.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Development.Shake.FilePath
66
import Control.Monad
77
import Data.List
88
import System.Directory ( copyFile )
9-
import System.FilePath ( searchPathSeparator )
9+
import System.FilePath ( searchPathSeparator, (</>) )
1010
import System.Environment ( lookupEnv, setEnv, getEnvironment )
1111
import BuildSystem
1212
import Version
@@ -108,22 +108,24 @@ withOriginalPath action = do
108108

109109
(Just paths, True) -> do
110110
snapshotDir <- trimmedStdout <$> execStackShake ["path", "--snapshot-install-root"]
111-
112-
let origPaths = removePathsContaining snapshotDir paths
111+
localInstallDir <- trimmedStdout <$> execStackShake ["path", "--local-install-dir"]
113112

114-
liftIO (setEnv "PATH" origPaths)
113+
let cacheBinPaths = [snapshotDir </> "bin", localInstallDir </> "bin"]
114+
let origPaths = removePathsContaining cacheBinPaths paths
115115

116+
liftIO (setEnv "PATH" origPaths)
116117
a <- action
117-
118118
liftIO (setEnv "PATH" paths)
119-
120119
return a
121120

122121
otherwise -> action
123122

124-
where removePathsContaining str path =
125-
joinPaths (filter (not.(isInfixOf str)) (splitPaths path))
123+
where removePathsContaining strs path =
124+
joinPaths (filter (not . containsAny) (splitPaths path))
125+
where containsAny p = any (`isInfixOf` p) strs
126+
126127
joinPaths = intercalate [searchPathSeparator]
128+
127129
splitPaths s =
128130
case dropWhile (== searchPathSeparator) s of
129131
"" -> []

0 commit comments

Comments
 (0)