36bd7e2
diff -ur stack-2.9.3.1/src/Path/Extra.hs stack-2.9.3.1.new/src/Path/Extra.hs
36bd7e2
--- stack-2.9.3.1/src/Path/Extra.hs	2023-06-22 18:40:54.000000000 +0800
36bd7e2
+++ stack-2.9.3.1.new/src/Path/Extra.hs	2023-08-08 13:55:22.550467487 +0800
36bd7e2
@@ -15,6 +15,8 @@
36bd7e2
   , pathToLazyByteString
36bd7e2
   , pathToText
36bd7e2
   , tryGetModificationTime
86537fd
+  ,forgivingResolveFile
86537fd
+  ,forgivingResolveFile'
86537fd
   ) where
86537fd
 
36bd7e2
 import           Data.Time ( UTCTime )
36bd7e2
@@ -27,6 +29,7 @@
86537fd
 import qualified Data.ByteString.Lazy.Char8 as BSL
86537fd
 import qualified Data.Text as T
86537fd
 import qualified Data.Text.Encoding as T
86537fd
+import qualified System.Directory as D
86537fd
 import qualified System.FilePath as FP
86537fd
 
86537fd
 -- | Convert to FilePath but don't add a trailing slash.
36bd7e2
@@ -121,3 +124,30 @@
86537fd
 
86537fd
 tryGetModificationTime :: MonadIO m => Path Abs File -> m (Either () UTCTime)
86537fd
 tryGetModificationTime = liftIO . tryJust (guard . isDoesNotExistError) . getModificationTime
86537fd
+
86537fd
+-- | 'Path.IO.resolveFile' (@path-io@ package) throws 'InvalidAbsFile' (@path@
86537fd
+-- package) if the file does not exist; this function yields 'Nothing'.
86537fd
+forgivingResolveFile ::
86537fd
+     MonadIO m
86537fd
+  => Path Abs Dir
86537fd
+     -- ^ Base directory
86537fd
+  -> FilePath
86537fd
+     -- ^ Path to resolve
86537fd
+  -> m (Maybe (Path Abs File))
86537fd
+forgivingResolveFile b p = liftIO $
86537fd
+  D.canonicalizePath (toFilePath b FP. p) >>= \cp ->
86537fd
+    catch
86537fd
+      (Just <$> parseAbsFile cp)
86537fd
+      ( \e -> case e of
86537fd
+          InvalidAbsFile _ -> pure Nothing
86537fd
+          _ -> throwIO e
86537fd
+      )
86537fd
+
86537fd
+-- | 'Path.IO.resolveFile'' (@path-io@ package) throws 'InvalidAbsFile' (@path@
86537fd
+-- package) if the file does not exist; this function yields 'Nothing'.
86537fd
+forgivingResolveFile' ::
86537fd
+     MonadIO m
86537fd
+  => FilePath
86537fd
+     -- ^ Path to resolve
86537fd
+  -> m (Maybe (Path Abs File))
86537fd
+forgivingResolveFile' p = getCurrentDir >>= flip forgivingResolveFile p
36bd7e2
diff -ur stack-2.9.3.1/src/Stack/Build/Execute.hs stack-2.9.3.1.new/src/Stack/Build/Execute.hs
36bd7e2
--- stack-2.9.3.1/src/Stack/Build/Execute.hs	2023-06-22 18:40:54.000000000 +0800
36bd7e2
+++ stack-2.9.3.1.new/src/Stack/Build/Execute.hs	2023-08-08 13:57:36.831258806 +0800
36bd7e2
@@ -66,6 +66,10 @@
86537fd
 import           Path
86537fd
 import           Path.CheckInstall
36bd7e2
 import           Path.Extra ( toFilePathNoTrailingSep, rejectMissingFile )
86537fd
+import           Path.Extra
86537fd
+                   ( forgivingResolveFile, rejectMissingFile
86537fd
+                   , toFilePathNoTrailingSep
86537fd
+                   )
36bd7e2
 import           Path.IO
36bd7e2
                    hiding ( findExecutable, makeAbsolute, withSystemTempDir )
36bd7e2
 import           RIO.Process
36bd7e2
@@ -548,7 +552,7 @@
86537fd
                 case loc of
86537fd
                     Snap -> snapBin
86537fd
                     Local -> localBin
86537fd
-        mfp <- liftIO $ forgivingAbsence (resolveFile bindir $ T.unpack name ++ ext)
86537fd
+        mfp <- liftIO $ forgivingResolveFile bindir (T.unpack name ++ ext)
86537fd
           >>= rejectMissingFile
86537fd
         case mfp of
86537fd
             Nothing -> do
36bd7e2
@@ -2195,7 +2199,7 @@
86537fd
         mabs <-
86537fd
             if isValidSuffix y
86537fd
                 then liftIO $ liftM (fmap ((T.takeWhile isSpace x <>) . T.pack . toFilePath)) $
86537fd
-                         forgivingAbsence (resolveFile pkgDir (T.unpack $ T.dropWhile isSpace x)) `catch`
86537fd
+                         forgivingResolveFile pkgDir (T.unpack $ T.dropWhile isSpace x) `catch`
36bd7e2
                              \(_ :: PathException) -> pure Nothing
36bd7e2
                 else pure Nothing
86537fd
         case mabs of
36bd7e2
diff -ur stack-2.9.3.1/src/Stack/ComponentFile.hs stack-2.9.3.1.new/src/Stack/ComponentFile.hs
36bd7e2
--- stack-2.9.3.1/src/Stack/ComponentFile.hs	2023-06-22 18:40:54.000000000 +0800
36bd7e2
+++ stack-2.9.3.1.new/src/Stack/ComponentFile.hs	2023-08-08 14:04:52.914859026 +0800
36bd7e2
@@ -283,8 +283,8 @@
36bd7e2
                         Iface.unList . Iface.dmods . Iface.deps
36bd7e2
           resolveFileDependency file = do
36bd7e2
             resolved <-
36bd7e2
-              liftIO (forgivingAbsence (resolveFile dir file)) >>=
36bd7e2
-                rejectMissingFile
36bd7e2
+              liftIO (forgivingResolveFile dir file) >>=
36bd7e2
+              rejectMissingFile
36bd7e2
             when (isNothing resolved) $
36bd7e2
               prettyWarnL
36bd7e2
               [ flow "Dependent file listed in:"
36bd7e2
diff -ur stack-2.9.3.1/src/Stack/Ghci.hs stack-2.9.3.1.new/src/Stack/Ghci.hs
36bd7e2
--- stack-2.9.3.1/src/Stack/Ghci.hs	2023-06-22 18:40:54.000000000 +0800
36bd7e2
+++ stack-2.9.3.1.new/src/Stack/Ghci.hs	2023-08-08 13:58:43.393651047 +0800
36bd7e2
@@ -29,7 +29,7 @@
86537fd
 import qualified Data.Text.Lazy.Encoding as TLE
86537fd
 import qualified Distribution.PackageDescription as C
86537fd
 import           Path
36bd7e2
-import           Path.Extra ( toFilePathNoTrailingSep )
86537fd
+import           Path.Extra (forgivingResolveFile', toFilePathNoTrailingSep)
36bd7e2
 import           Path.IO hiding ( withSystemTempDir )
36bd7e2
 import           RIO.Process
36bd7e2
                    ( HasProcessContext, exec, proc, readProcess_
36bd7e2
@@ -225,7 +225,7 @@
86537fd
         then do
86537fd
             fileTargets <- forM fileTargetsRaw $ \fp0 -> do
86537fd
                 let fp = T.unpack fp0
86537fd
-                mpath <- liftIO $ forgivingAbsence (resolveFile' fp)
86537fd
+                mpath <- liftIO $ forgivingResolveFile' fp
86537fd
                 case mpath of
86537fd
                     Nothing -> throwM (MissingFileTarget fp)
36bd7e2
                     Just path -> pure path
36bd7e2
diff -ur stack-2.9.3.1/src/Stack/PackageFile.hs stack-2.9.3.1.new/src/Stack/PackageFile.hs
36bd7e2
--- stack-2.9.3.1/src/Stack/PackageFile.hs	2023-06-22 18:40:54.000000000 +0800
36bd7e2
+++ stack-2.9.3.1.new/src/Stack/PackageFile.hs	2023-08-08 14:06:21.163396729 +0800
36bd7e2
@@ -34,7 +34,7 @@
36bd7e2
                   -> RIO GetPackageFileContext (Maybe (Path Abs File))
86537fd
 resolveFileOrWarn = resolveOrWarn "File" f
36bd7e2
  where
36bd7e2
-  f p x = liftIO (forgivingAbsence (resolveFile p x)) >>= rejectMissingFile
36bd7e2
+  f p x = liftIO (forgivingResolveFile p x) >>= rejectMissingFile
86537fd
 
36bd7e2
 -- | Get all files referenced by the package.
36bd7e2
 packageDescModulesAndFiles