Skip to content

Commit 71edb7d

Browse files
committed
Merge pull request #2680 from BardurArantsson/sandbox-config-does-not-exist
Exit with an error if $CABAL_SANDBOX_CONFIG does not point to extant file
2 parents 94369a1 + 3488f59 commit 71edb7d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cabal-install/Distribution/Client/Sandbox.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ import Control.Exception ( assert, bracket_ )
108108
import Control.Monad ( forM, liftM2, unless, when )
109109
import Data.Bits ( shiftL, shiftR, xor )
110110
import Data.Char ( ord )
111+
import Data.Foldable ( forM_ )
111112
import Data.IORef ( newIORef, writeIORef, readIORef )
112113
import Data.List ( delete, foldl' )
113114
import Data.Maybe ( fromJust )
@@ -176,7 +177,11 @@ updateSandboxConfigFileFlag globalFlags =
176177
case globalSandboxConfigFile globalFlags of
177178
Flag _ -> return globalFlags
178179
NoFlag -> do
179-
f' <- fmap (maybe NoFlag Flag) . lookupEnv $ "CABAL_SANDBOX_CONFIG"
180+
fp <- lookupEnv "CABAL_SANDBOX_CONFIG"
181+
forM_ fp $ \fp' -> do -- Check for existence if environment variable set
182+
exists <- doesFileExist fp'
183+
unless exists $ die $ "Cabal sandbox file in $CABAL_SANDBOX_CONFIG does not exist: " ++ fp'
184+
let f' = maybe NoFlag Flag fp
180185
return globalFlags { globalSandboxConfigFile = f' }
181186

182187
-- | Return the path to the sandbox config file - either the default or the one

0 commit comments

Comments
 (0)