summaryrefslogtreecommitdiff
path: root/compiler/main/Packages.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-03-11 10:44:03 +0100
committerBen Gamari <ben@smart-cactus.org>2016-03-11 13:20:20 +0100
commit2908ae8dbe8fd69f8c3ac3dab199026dfc250445 (patch)
tree876e27d90bff300020d63d4691423ef9481abf0a /compiler/main/Packages.hs
parente764ede35f5c5b2c41e1670c6a9b831e0a70cd17 (diff)
downloadhaskell-2908ae8dbe8fd69f8c3ac3dab199026dfc250445.tar.gz
Handle unset HOME environment variable more gracefully
Test Plan: * Validate * try `env -i ghc` * try `env -i runghc HelloWorld.hs` Reviewers: austin Subscribers: thomie, ezyang Differential Revision: https://phabricator.haskell.org/D1971 GHC Trac Issues: #11678
Diffstat (limited to 'compiler/main/Packages.hs')
-rw-r--r--compiler/main/Packages.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index decd7a1019..2655c451d8 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -384,11 +384,11 @@ resolvePackageConfig dflags GlobalPkgConf = return $ Just (systemPackageConfig d
-- NB: This logic is reimplemented in Cabal, so if you change it,
-- make sure you update Cabal. (Or, better yet, dump it in the
-- compiler info so Cabal can use the info.)
-resolvePackageConfig dflags UserPkgConf = handleIO (\_ -> return Nothing) $ do
+resolvePackageConfig dflags UserPkgConf = runMaybeT $ do
dir <- versionedAppDir dflags
let pkgconf = dir </> "package.conf.d"
- exist <- doesDirectoryExist pkgconf
- return $ if exist then Just pkgconf else Nothing
+ exist <- tryMaybeT $ doesDirectoryExist pkgconf
+ if exist then return pkgconf else mzero
resolvePackageConfig _ (PkgConfFile name) = return $ Just name
readPackageConfig :: DynFlags -> FilePath -> IO (FilePath, [PackageConfig])