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

Commit c253cbb

Browse files
authored
Merge pull request #1437 from jneira/ignore-unset-path
Ignore the stack PATH fix if the env var is not set
2 parents 0bbec7d + b089c8b commit c253cbb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

install/src/Stack.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ module Stack where
33
import Development.Shake
44
import Development.Shake.Command
55
import Development.Shake.FilePath
6+
import Control.Exception
67
import Control.Monad
78
import Data.List
89
import System.Directory ( copyFile )
910
import System.FilePath ( searchPathSeparator, (</>) )
1011
import System.Environment ( lookupEnv, setEnv, getEnvironment )
12+
import System.IO.Error ( isDoesNotExistError )
1113
import BuildSystem
1214
import Version
1315
import Print
@@ -102,7 +104,11 @@ stackBuildFailMsg =
102104
-- |Run actions without the stack cached binaries
103105
withoutStackCachedBinaries :: Action a -> Action a
104106
withoutStackCachedBinaries action = do
105-
mbPath <- liftIO (lookupEnv "PATH")
107+
108+
let getEnvErrorHandler e | isDoesNotExistError e = return Nothing
109+
| otherwise = throwIO e
110+
111+
mbPath <- liftIO (lookupEnv "PATH" `catch` getEnvErrorHandler)
106112

107113
case (mbPath, isRunFromStack) of
108114

0 commit comments

Comments
 (0)