@@ -50,7 +50,8 @@ import System.Environment
5050import System.Exit (ExitCode (..))
5151import System.FilePath
5252import System.IO (stdout)
53−import System.IO.Temp (withSystemTempDirectory, withTempFile)
53+import System.IO.Temp (withSystemTempDirectory, withTempDirectory,
54+ withTempFile)
5455#if MIN_VERSION_base(4,8,3)
5556import System.IO.Error (IOError, isDoesNotExistError)
5657#else
@@ -102,7 +103,15 @@ makePDF program pdfargs writer opts doc = do
102103 baseProg -> do
103104 commonState <- getCommonState
104105 verbosity <- getVerbosity
105− liftIO $ withSystemTempDirectory "tex2pdf." $ \tmpdir -> do
106+ -- latex has trouble with tildes in paths, which
107+ -- you find in Windows temp dir paths with longer
108+ -- user names (see #777)
109+ let withTempDir templ action = do
110+ tmp <- getTemporaryDirectory
111+ if '~' `elem` tmp
112+ then withTempDirectory "." templ action
113+ else withSystemTempDirectory templ action
114+ liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do
106115 source <- runIOorExplode $ do
107116 putCommonState commonState
108117 doc' <- handleImages tmpdir doc