@@ -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 (readProcessWithExitCode)
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,13 @@ 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
94+ (do (ec, sout, _) <- readProcessWithExitCode "uname" ["-o"] ""
96+ then return $ Just sout
98+ (\(_ :: E.SomeException) -> return Nothing)
92− if '~' `elem` tmp
99+ if '~' `elem` tmp || uname == Just "Cygwin" -- see #5451
93 then withTempDirectory "." templ action
100 then withTempDirectory "." templ action
94 else withSystemTempDirectory templ action
101 else withSystemTempDirectory templ action
95 (newCommonState, res) <- liftIO $ withTempDir "tex2pdf." $ \tmpdir' -> do
102 (newCommonState, res) <- liftIO $ withTempDir "tex2pdf." $ \tmpdir' -> do