@@ -6,7 +6,7 @@ import Development.Shake.FilePath
66import Control.Monad
77import Data.List
88import System.Directory ( copyFile )
9- import System.FilePath ( searchPathSeparator )
9+ import System.FilePath ( searchPathSeparator , (</>) )
1010import System.Environment ( lookupEnv , setEnv , getEnvironment )
1111import BuildSystem
1212import 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