jgm / gitit

A wiki using HAppS, pandoc, and git
GNU General Public License v2.0
2.15k stars 226 forks source link

server error during PDF Export #271

Closed tantignac closed 13 years ago

tantignac commented 13 years ago

I get this error message when clicking on the PDF Export button: Server error: /var/folders/bg/szy711t55qqgs0sssfxdj36h0000gn/T/gitit-tmp-pdf.0/export.log: openBinaryFile: does not exist (No such file or directory)

My config is Mac OS X 10.7.1 and the last Haskell Platform.

Would you have any idea if it is a bug or if I missed something?

jgm commented 13 years ago

I'm not sure how good gitit's error checking is. My guess is that there's an issue with your latex setup -- perhaps latex is in a path that your gitit process can't see?

+++ Thibaud Antignac [Sep 08 11 01:23 ]:

I get this error message when clicking on the PDF Export button: Server error: /var/folders/bg/szy711t55qqgs0sssfxdj36h0000gn/T/gitit-tmp-pdf.0/export.log: openBinaryFile: does not exist (No such file or directory)

My config is Mac OS X 10.7.1 and the last Haskell Platform.

Would you have any idea if it is a bug or if I missed something?

Reply to this email directly or view it on GitHub: https://github.com/jgm/gitit/issues/271

tantignac commented 13 years ago

I do not know how to be sure gitit can access to latex.

However, the citation preview works well in BibDesk (I guess it uses latex) and it is the same (works well) when I compile LaTeX code with TexShop.

My installation of GHC and so gitit are in my normal session. I did not use any particular configuration (as far as I know).

tantignac commented 13 years ago

Finally, I managed to have some informations.

Does it help? I avow that I am a bit lost: I have no idea where it could come from...

jgm commented 13 years ago

Puzzling. Do you know any Haskell? It might be useful to insert some debugging statements, recompile, and try again.

Here's what I'd suggest. Check out the code from github.

In Network/Gitit/Util.hs, line 56, replace removeDirectoryRecursive with return ().

This will modify withTempDir so that it doesn't delete the temp directory; you can then examine it. To make this easier, in Network/Gitit/Export.hs, after line 232 (runShellCommand), insert the line liftIO $ print tempdir.

This should cause gitit to print the tempdir it is using to make the PDF. Recompile with cabal install gitit, then run, and try to export a PDF. Before it fails, it shuold tell you the tempdir. You can then go there and see what it contains.

+++ Thibaud Antignac [Sep 14 11 08:12 ]:

Finally, I managed to have some informations.

  • gitit is run on my behalf: (checked in the Activity Monitor)
  • latex is in /usr/texbin: user:~ user$ which latex /usr/texbin/latex
  • latex is executable by all users (so including myself): user:texbin user$ ls -l latex lrwxr-xr-x 1 root wheel 6 6 sep 15:46 latex -> pdftex
  • This is the TEMPDIR: user:T user$ echo $TMPDIR /var/folders/bg/szy711t55qqgs0sssfxdj36h0000gn/T/
  • The TEMPDIR is writable by myself (and so gitit) user:szy711t55qqgs0sssfxdj36h0000gn user$ ls -l drwx------ 14 user staff 476 14 sep 16:29 T
  • Finally, each time I try to export a PDF, I get in the kernel.log of the Console: kernel[0]: nstat_lookup_entry failed: 2

Does it help? I avow that I am a bit lost: I have no idea where it could come from...

Reply to this email directly or view it on GitHub: https://github.com/jgm/gitit/issues/271#issuecomment-2094158

tantignac commented 13 years ago

Thank you for the details. However, I am not very familiar with Haskell...

However, I think I can follow your instructions, except the part of recompiling: how can I indicate to cabal that it has to take my modified version and not the version on the remote Haskell repository? A last point, do not I need to add the --reinstall flag?

ehamberg commented 13 years ago

tantignac: if you simply run “cabal install” (i.e. not “cabal install gitit”) in the source directory it should recompile and install that version.

tantignac commented 13 years ago

ehamberg: Thank you for the tip, it worked!

jgm: There is a problem in the compilation:

    Couldn't match expected type `(FilePath -> IO a) -> IO a'
                with actual type `IO c0'
    In the return type of a call of `bracket'
    In the expression: bracket (createTempDir 0 baseName) return ()
    In an equation for `withTempDir':
        withTempDir baseName = bracket (createTempDir 0 baseName) return ()```

For information, here are the lines after my modifications:

```haskell
-- | Perform a function in a temporary directory and clean up.
withTempDir :: FilePath -> (FilePath -> IO a) -> IO a
withTempDir baseName = bracket (createTempDir 0 baseName) return()
jgm commented 13 years ago

+++ Thibaud Antignac [Sep 14 11 09:38 ]:

ehamberg: Thank you for the tip, it worked!

jgm: There is a problem in the compilation:

    Couldn't match expected type `(FilePath -> IO a) -> IO a'
                with actual type `IO c0'
    In the return type of a call of `bracket'
    In the expression: bracket (createTempDir 0 baseName) return ()
    In an equation for `withTempDir':
        withTempDir baseName = bracket (createTempDir 0 baseName) return ()```

For information, here are the lines after my modifications:

```haskell
-- | Perform a function in a temporary directory and clean up.
withTempDir :: FilePath -> (FilePath -> IO a) -> IO a
withTempDir baseName = bracket (createTempDir 0 baseName) return()

Sorry: Just delete the () after return.

tantignac commented 13 years ago

I just made the test. A temporary file is created in the temporary folder 'gitit-tmp.pdf.0':'export.tex' (and only this file, no auxiliaries ones that latex generally outputs.

So the problem seems to come from somewhere between the call and the output of latex. I precise that latex is in my PATH: user:mywiki user$ which latex /usr/texbin/latex user:mywiki user$ echo $PATH /Users/user/Library/Haskell/bin:/Library/Frameworks/Python.framework/Versions/3.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin

I add that I have this problem on my two Mac and that this export to pdf worked before I install Lion on one of them (the other run also under Lion).

Just for information, the markdown2pdf wrapper of pandoc works when I use it from the terminal.

jgm commented 13 years ago

One possibility is that, although your texbin directory is in your path when you start up a terminal session, it's not in the path in the shell gitit starts up. There are many places to set paths on OSX, and some affect only terminal sessions. You might look into adding /usr/texbin to the path at a higher level, if you're currently doing so in .bashrc or some such.

As a test, you could try symlinking /usr/bin/pdflatex to /usr/texbin/pdflatex, and see if that helps things.

My gitit on OSX setup works fine - but I'm not on my Mac right now, so I can't look into how the paths are set.

+++ Thibaud Antignac [Sep 15 11 00:27 ]:

I just made the test. A temporary file is created in the temporary folder 'gitit-tmp.pdf.0':'export.tex' (and only this file, no auxiliaries ones that latex generally outputs.

So the problem seems to come from somewhere between the call and the output of latex. I precise that latex is in my PATH: user:mywiki user$ which latex /usr/texbin/latex user:mywiki user$ echo $PATH /Users/user/Library/Haskell/bin:/Library/Frameworks/Python.framework/Versions/3.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin

I add that I have this problem on my two Mac and that this export to pdf worked before I install Lion on one of them (the other run also under Lion).

Just for information, the markdown2pdf wrapper of pandoc works when I use it from the terminal.

Reply to this email directly or view it on GitHub: https://github.com/jgm/gitit/issues/271#issuecomment-2101773

tantignac commented 13 years ago

You found the problem.

I just set these three symlinks: sudo ln -s /usr/texbin/latex /usr/bin/latex sudo ln -s /usr/texbin/pdflatex /usr/bin/pdflatex sudo ln -s /usr/texbin/pdftex /usr/bin/pdftex and it works.

It worked before my updating to Lion. So I suppose that Lion changed some little things in the PATH (or I may have changed something myself but, I actually don't see what...).

Anyway, thank you very much for your help for this problem not really related to gitit :)