Skip to content

[R-pkg-devel] Problem compressing vignettes for CRAN

7 messages · Michael Dewey, Ivan Krylov, Jeff Newmiller

#
I am trying to update my CRAN package metap. When I ran a final check on 
winbuilder I got the warning

* checking sizes of PDF files under 'inst/doc' ... WARNING
   'gs+qpdf' made some significant size reductions:
      compacted 'compare.pdf' from 498Kb to 243Kb
      compacted 'plotmetap.pdf' from 349Kb to 91Kb
   consider running tools::compactPDF(gs_quality = "ebook") on these files,
   or build the source package with --compact-vignettes=both

But I did use the option --compact-vignettes=both when I built the tarball.

I do have gs installed but not qpdf. I built the package under Windows 
if that is relevant.

Any suggestions?
#
? Fri, 6 Oct 2023 15:36:45 +0100
Michael Dewey <lists at dewey.myzen.co.uk> ?????:
Is the Ghostscript executable on the %PATH%? It might help to install a
newer version. It may also be informative to extract the vignette *.pdf
files from the source package tarball and run tools::compactPDF(pdfs,
gs_quality='ebook', verbose = TRUE) to see whether it breaks at any
point.
#
Dear Ivan

You must have psychic powers. After some digging I find that the copy 
installed by TexLive is hidden from other software so I need to install 
it again. I suppose while I am at it I should try installing qpdf.

Michael
On 06/10/2023 15:48, Ivan Krylov wrote:

  
    
2 days later
#
Following on from Ivan's advice I have now installed qpdf and Ghostview. 
I have checked that they are both on my path by typing their name at the 
command line and verifying they open. I then built the package with the 
--compress-vignettes=both and then checked it with --as-cran I still get 
a complaint that it needs qpdf to check compression.

I notice that in the Writing R Extensions manual in section 1.6.1 it states
"The full path to the qpdf command can be supplied as environment 
variable R_QPDF ..."

Is that a typo for "must be supplied"? If it is where can I find the 
answers to questions about how R accepts Windows paths? Do I need to 
enclose parts of names containing spaces in "" signs? Does it mean the 
path up to, in this case, bin or must I include qpdf.exe after it?

I assume I do not need to do anything special to get it to find Ghostscript?

Michael
On 06/10/2023 16:30, Michael Dewey wrote:

  
    
#
On Sun, 8 Oct 2023 16:47:41 +0100
Michael Dewey <lists at dewey.myzen.co.uk> wrote:

            
While running R, does Sys.which('qpdf') return the path to qpdf.exe?
Does Sys.getenv('PATH') match your expectations?
Well, R tries to resolve the path to qpdf.exe using Sys.which(), so it
must work if it's on the %PATH%, but if all else fails, setting this
environment variable should help.
It always depends on how the final command line is built by a
particular function, but it should work by taking plain file paths
without any escaping and quotation. The directory separators shouldn't
matter either.

(tools::compactPDF uses system2(), so it quotes the path to the
executable by itself.)
It must be the full path to the executable, including the final
qpdf.exe.
tools::compactPDF() expects gswin64c.exe or gswin32c.exe on the PATH.
If it's not there, R_GSCMD must be set to the full path to the
executable. Judging by the NOTE you've received, it's Ghostscript that
performed most of the compaction in your case.
#
Dear Ivan (and list)

Using Ivan's advice I traced the problem to a difference of opinio 
between Microsoft and R about paht names. I had mistakenly enclosed 
parts of the names in "" which was fine for MS but not R. Sys.which() 
was my saviour here.

Many thanks to Ivan for broadening my knowledge of useful functions like 
Sys.which().

Michael
On 09/10/2023 08:51, Ivan Krylov wrote:

  
    
#
R could care less about what is in PATH... there is however a difference between Windows parsing PATH and how CMD lets you quote things interactively.

The whole point of PATH is to let you or R provide simple program names like qpdf without knowing where they are... Windows takes over and looks up where the program actually is based on the contents of PATH. How you get things into that environment variable can vary depending on which software you are using (CMD and R are two possible options), but the actual content is handled by the operating system (which is why PATH on Linux is formatted differently than PATH on Windows).
On October 9, 2023 8:22:17 AM PDT, Michael Dewey <lists at dewey.myzen.co.uk> wrote: