macOS Sierra compatibility?

Issue #58 new
Florian Egermann created an issue


i tried to install CUPS-PDF under Sierra (10.12.6). A popup says "This might damage your computer", so before i try that: Is CUPS-PDF compatible with macOS Sierra?


Comments (26)

  1. Brandon Payne

    Same problem with High Sierra. What's the work around? Sent to use this with screenwriter.el in emacs. Does CUPS-PDF install from the MAKEFILE, just not the .package? Or is it /really/ incompatible with Sierra and High Sierra. An earlier note is about El Capitan. Was that when the breaking change happened that everything goes into /usr/local/bin not /usr/bin. Is it a small line like that that's keeping this from building/installing?

  2. Marco Vedovati

    The issue seems to be related to the system() function call in cups-pdf/src/cups-pdf.c failing to run. It is supposed to run the command:

    /usr/bin/pstopdf -o outfile spoolfile

    You can see the problem if you increase the log level in /etc/cups/cups-pds.con to 4 (you will see a bad return code for gscall).

    However if you invoke pstopdf from terminal it works....

    I tried replacing system() with execl() but it doesnt get any better.

    Wondering how I can debug this ...

  3. Marco Vedovati

    BTW, despite package installation failing you can still add the CUPS-PDF printer and you can see it working by monitoring the log file with tail -f /var/log/cups/cups-pdf_log and just trying to print something.

    Manually add cups-pdf.conf to /etc/cups in case it's missing.

  4. Marco Vedovati

    I investigated a little bit more and the problem is definitely with the system() that is used to invoke the /usr/bin/pstopdf tool that converts the ps file in the spool to the pdf file.

    What I found is that the executable you run with system() is not be able to create any file! I replaced the system() with popen() to capture the stdout and stderr and this is what I get: PSNormalizer couldn't create temporary directory from the template /tmp//PSNormalizer.u7RP4i due to error Operation not permitted!/usr/bin/pstopdf failed on file /var/spool/cups-pdf/SPOOL/cups2pdf-2563 with error code -30995

    Similarly I tried running the system() on a dummy executable that all it does is a open("dummy", O_CREAT | O_WRONLY); and this open fails as well with operation not permitted. I am 100% the destination path is rwx.

    A.t.m. I have no clue of what else it could be done...

  5. Marco Vedovati

    As a workaround (or better "bodge"), I replaced the system() with a cp() function that simply copies the file in the spool to the cups-pdf destination folder (be sure to suffix this file with .eps).

    Since this file is a Postscript file, it can be nicely opened by Preview and then saved to PDF.

    Well...better than nothing :-)

  6. Fred

    What file did you modify? I grepped the source directory and couldn't find any instances of system(). If I can output an EPS file I can set up a LaunchAgent to watch the output directory and convert that file to PDF with /usr/bin/pstopdf.

  7. zachshulman

    hey guys, ill be honest im terrible with computers and trying to understand this thread isn't easy. i have a couple questions and would love if someone could help me out.

    (1) is CUPS-PDF compatible with my laptop? I have mac OS high sierra version 10.13.1 running safari version 11.0.1

    (2) I am trying to find a way to change the default printer setting on my laptop. i want to turn off "auto rotate" and i want to change "scale" to "scale to fit: print entire page" .. such that when i print any PDF, image ext. it will always open to these new settings and not the original default settings. is CUPS-PDF my fix? if so, please help me install it.

  8. Harsimran Walia

    In case someone is still facing issue with getting it to work with sierra. I made the following changes to the cups-pdf.conf and got it working.

    • GhostScript /usr/bin/pstopdf
    • GSCall %s %s -o %s %s
    • PDFVer
  9. jackoverfull

    Harsimran, what changes did you make exactly? I've checked my conf file and it seems it's already as you wrote, yet nothing gets printed.

  10. Harsimran Walia

    I made only the above stated 3 changes to the file. I guess you may be missing the space after PDFVer PDFVer " " (without the quotes)

  11. jackoverfull

    Nope. There is already a space at the end by default, I even tried applying another one or giving a specific version but no change. I've seen something appearing in the spool folder for an instant at a certain point, though.

  12. Harsimran Walia

    In that case you would have to comment out the following code in cups-pdf/src/cups-pdf.c

    /*(void) unlink(outfile); log_event(CPDEBUG, "output file unlinked", outfile);*/

    Compile it again and use the new binary

  13. Deepanshu Pandey

    Hey can someone help me out, I have mac os high sierra and it had cups-pdf version 2.2.5 pre installed and it gave successful prints though i had to copy the cups-pdf.conf to /etc/cups manually , I by mistake deleted the username folder in the default directory in which cups saves outputs. I created that folder again using

    mkdir username

    in the directory /var/spool/cups-pdf/ now even though in the logs it shows success during printing and checking logs via

    tail -f /var/log/cups/cups-pdf_log

    but the output is not saving in the output directory not even if i change it .. my cups-pdf.conf file is exactly the same as in this repo.

    Please help , the main problem started after i deleted the folder am i missing something by just recreating it using mkdir , does it have more components.

  14. Deepanshu Pandey

    Okay so I fixed the issue , going according to @marcov i enabled debugging in cups-pdf.conf and also in cupsd.conf . As mentioned the problem was indeed in line 800 of system call and checking in the /var/log/cups/error_log with log level as debug the gs command line always stated pstopdf failed with error code 13. As 13 states permission denied i googled around a bit and came across this thread.

    Here martin eric talks about ownership fixes for ps to pdf conversion smoothly : -

    What we ship is /var/spool/cups-pdf/ANONYMOUS and our post-install
    script fixes permissions and ownership as follow:
    chown nobody:nogroup /var/spool/cups-pdf/ANONYMOUS
    chmod 1777 /var/spool/cups-pdf/ANONYMOUS

    so basically the folder in which the final output pdf is to be generated should not have root ownership that would require sudo to write onto and thus it returned with error code 13. So @marcov do try to change the ownership rights of folder you were trying to save pdf in and let me know if that worked, for me it was a success :)

  15. Marco Vedovati

    @deepanshu No, I dont think it's the same issue the one mentioned in the Debian bug report. It's instead something related to the system() call specifically when invoked by cups-pdf.

    Another test I did is the following:

    • I wrote a 1st dummy program (fake-pstopdf) that all it does is creating a fake file in the /var/spool/.../ directory:
    int main(void)
      int f = open("/var/spool/cups-pdf/marco/fake-pdf.pdf", O_CREAT | O_WRONLY);
      int r;
      if (f < 0) return errno;
      r = write(f, "foobar", 6);
      r = close(f);
      return 0;
    • I wrote a 2nd dummy program (fake-cups-pdf) that all it does it calling system() wih argument the 1st dummy program
    #include <stdio.h>
    #include <stdlib.h>
    int main(void)
        int ret = system("/var/spool/cups-pdf/marco/fake-pstopdf");
        printf("System done, retcode=%d", ret);
        return 0;
    • I replaced /usr/libexec/cups/backend/cups-pdf with my fake-cups-pdf. In this setup, when printing something, the fake pdf file is correctly create into /var/spool/....

    • However, if the fake-pstopdf is invoked by the system in the (original) cups-pdf, then the fake pdf is not generated. So there's something in the cups-pdf code not allowing the pdf to be generated.

  16. Deepanshu Pandey

    @marcov In your fake-pstopdf experiment by system in original cups-pdf, what was the error code you were receiving ? did you tail the /var/log/cups/error_log ? I am curious if its not error code 13 then you are right there must be some other issue with the cups-pdf binary

  17. Marco Vedovati

    @deepanshu Sorry I have to correct myself, in the case you are mentioning the fake pdf is indeed created:

    $ sudo tail -f /var/log/cups/cups-pdf_log 
    Fri Dec 22 19:38:06 2017  [DEBUG] system() completed  (completed command='/usr/bin/pstopdf  -o /var/spool/cups-pdf/marco/job_392-LettreResil_2.pdf /var/spool/cups-pdf/SPOOL/cups2pdf-2311' code=-19 (0xed00))
    Fri Dec 22 19:38:06 2017  [DEBUG] system() completed  (command='/var/spool/cups-pdf/marco/fake-pstopdf' code=0 (0x0))  
  18. Marco Vedovati

    OK so the problem is more related to pstopdf rather than the system() call. (I dont know why before I would obtain a different behaviour).

  19. Deepanshu Pandey

    @marcov exactly pstopdf faced failure due to writing permissions . I hope this solves the issue for others too.

  20. John Bent

    I was having the same exact problem with the system(gscall) failing. I followed deepanshu's instructions about setting the permissions on my username file in var/spool/cups-pdf/ and it works now!

  21. Jesse Reynolds

    Thanks for making this package.

    I tried installing on Sierra 10.12.6 and appear to be having similar symptoms. The following directories are created, but no files are to be found in any of them afterwards:

    ├── SPOOL
    └── jesse

    I tried setting log level to 4 in cups-pdf.conf and to debug in cups.conf and can see no errors, just looks like success:

    Tue May 22 09:30:47 2018  [DEBUG] all data written to spoolfile (/var/spool/cups-pdf/SPOOL/cups2pdf-31275)
    Tue May 22 09:30:47 2018  [DEBUG] output filename created (/var/spool/cups-pdf/jesse/job_255-Untitled.pdf)
    Tue May 22 09:30:47 2018  [DEBUG] ghostscript commandline built (/usr/bin/pstopdf  -o /var/spool/cups-pdf/jesse/job_255-Untitled.pdf /var/spool/cups-pdf/SPOOL/cups2pdf-31275)
    Tue May 22 09:30:47 2018  [DEBUG] output file unlinked (/var/spool/cups-pdf/jesse/job_255-Untitled.pdf)
    Tue May 22 09:30:48 2018  [DEBUG] spoolfile unlinked (/var/spool/cups-pdf/SPOOL/cups2pdf-31275)

    I did also follow the steps to create a null printer but I'm not sure how to use that to help the setup?

    Is there a patch to the source code I should try applying?

  22. Log in to comment