@@ -42,6 +42,7 @@ import Text.Pandoc.Error (PandocError (PandocPDFProgramNotFoundError))
42import Text.Pandoc.MIME (getMimeType)
42import Text.Pandoc.MIME (getMimeType)
43import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..))
43import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..))
44import Text.Pandoc.Process (pipeProcess)
44import Text.Pandoc.Process (pipeProcess)
45+import System.Process (readProcess)
45import Text.Pandoc.Shared (inDirectory, stringify)
46import Text.Pandoc.Shared (inDirectory, stringify)
46import qualified Text.Pandoc.UTF8 as UTF8
47import qualified Text.Pandoc.UTF8 as UTF8
47import Text.Pandoc.Walk (walkM)
48import Text.Pandoc.Walk (walkM)
@@ -89,7 +90,9 @@ makePDF program pdfargs writer opts doc =
89 -- user names (see #777)
90 -- user names (see #777)
90 let withTempDir templ action = do
91 let withTempDir templ action = do
91 tmp <- getTemporaryDirectory
92 tmp <- getTemporaryDirectory
93+ uname <- E.catch (readProcess "uname" ["-o"] "")
94+ (\(_ :: E.SomeException) -> return "")
92− if '~' `elem` tmp
95+ if '~' `elem` tmp || uname == "Cygwin" -- see #5451
93 then withTempDirectory "." templ action
96 then withTempDirectory "." templ action
94 else withSystemTempDirectory templ action
97 else withSystemTempDirectory templ action
95 (newCommonState, res) <- liftIO $ withTempDir "tex2pdf." $ \tmpdir' -> do
98 (newCommonState, res) <- liftIO $ withTempDir "tex2pdf." $ \tmpdir' -> do