Create ~/.ghc/ if it doesn't already exist; fixes trac #4522
authorIan Lynagh <igloo@earth.li>
Sat, 18 Dec 2010 18:49:25 +0000 (18:49 +0000)
committerIan Lynagh <igloo@earth.li>
Sat, 18 Dec 2010 18:49:25 +0000 (18:49 +0000)
ghc/InteractiveUI.hs

index a2ba64e..5a26324 100644 (file)
@@ -369,14 +369,16 @@ interactiveUI srcs maybe_exprs = do
 
 withGhcAppData :: (FilePath -> IO a) -> IO a -> IO a
 withGhcAppData right left = do
-   either_dir <- IO.try (getAppUserDataDirectory "ghc")
-   case either_dir of
-      Right dir -> right dir
-      _ -> left
+    either_dir <- IO.try (getAppUserDataDirectory "ghc")
+    case either_dir of
+        Right dir ->
+            do createDirectoryIfMissing False dir `catchIO` \_ -> return ()
+               right dir
+        _ -> left
 
 runGHCi :: [(FilePath, Maybe Phase)] -> Maybe [String] -> GHCi ()
 runGHCi paths maybe_exprs = do
-  let 
+  let
    read_dot_files = not opt_IgnoreDotGhci
 
    current_dir = return (Just ".ghci")