23

I am trying to check a package that I have built (with vignette) using R CMD check --as-cran [my package] in my windows command prompt. All goes well until I get the message,

WARNING 'qpdf' is needed for checks on size reduction of PDFs

I have downloaded qpdf, put the unzipped folder in my program files directory, and added the bin folder to the PATH.

Not quite sure what else I need to do? I have the feeling I have not installed qpdf correctly or I need to build this program itself? I have read through the readme files and manual for qpdf which appear to be more aimed at unix users (which I have no experience with... I am your standard/regular windows user with little to no programming experience outside of statistical languages). I have had a go at trying to build qpdf using cgywin, but ended up failing to install zlib and prec. Any tips?

guyabel
  • 8,014
  • 6
  • 57
  • 86
  • @Ben Thanks for the advice. Fixed it now. The commands you suggested showed that I did not have the qpdf.exe. In the end I had downloaded the wrong version of qpdf (i had the standard version, when I needed the qpdf--bin-mingw32.zip). I unzipped this and changed the path, and now I no longer get a `WARNING` message from the check.....i do however get a `NOTE Unable to find GhostScript executable to run checks on size reduction`... this is a new mystery. I think I will start a new question so as to separate the issues for anyone future reader – guyabel Aug 01 '12 at 10:23
  • Setting your GhostScript executable (e.g., C:\Program Files (x86)\gs\gs9.19\bin\gswin32c.exe) to "R_GSCMD" removes the NOTE "Unable to find GhostScript executable to run checks on size reduction”. To set, in the R console do: `Sys.setenv(R_GSCMD = "C:\\Program Files (x86)\\gs\\gs9.19\\bin\\gswin32c.exe")` – Erdogan CEVHER May 13 '16 at 06:36
  • 1
    Adding "C:\Program Files (x86)\gs\gs9.19\bin\" to "Path" variable in System Environment Variables solves "Unable to find GhostScript executable..." issue permanently (for every R session). To add: My Computer - rightclick - properties - Advanced system settings - Advanced tab in System Properties window - Environment variables - Click "Path" in System variables - Edit - add ";C:\Program Files (x86)\gs\gs9.19\bin\" to the end of line. – Erdogan CEVHER May 13 '16 at 07:05

5 Answers5

13

I would try

Sys.which(Sys.getenv("R_QPDF", "qpdf"))
Sys.getenv("PATH")

to establish that R is really not finding the qpdf executable, and see where it is looking. You probably shouldn't need to rebuild everything, just figure out why R is not finding the qpdf executable ... does running qpdf from a terminal window work ... ? How are you starting R, and did it have a chance to get the new PATH definition (i.e. do you need to open a new terminal window, or ?? reboot ??)

The incantation above was extracted from tools::compactPDF, from the default value of the qpdf argument, on a Linux machine. You should check for yourself, in case (e.g.) the Windows version is looking for qpdf.exe rather than qpdf ...

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • 2
    also see [this answer](http://stackoverflow.com/questions/16956875/how-can-i-install-qpdf-on-mac-10-8-3) on how to actually install `qpdf`, at least on OS X. – maxheld Aug 15 '16 at 21:11
3

There are a couple of other things to consider on a Windows machine:

If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 7.0 is listed here).

Once you have extracted the zipped qpdf directory to your hard disk, perhaps under C:\Program Files\, added C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables, and re-launched R, Windows needs to establish that pqdf is safe to run.

Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.

Martin Smith
  • 3,687
  • 1
  • 24
  • 51
1

I got the same warning on Ubuntu so here's a Ubuntu solution for completeness:

First update packages

sudo apt update

Then install qpdf with

sudo apt install qpdf

Tested on Ubuntu 20.04.

epo3
  • 2,991
  • 2
  • 33
  • 60
0

Recent developments: If you install Rtools 3.5 qpdf is included and that warning is gone. Rtools is a toolset for building packages on Windows and is recently reworked by Jeroen Ooms.

More information : https://cran.r-project.org/bin/windows/Rtools/

Note that the changelog is incomplete, as Rtools 3.5 isn't frozen yet at the time of writing (2019-03-01). Even though it's not visible on the page yet, qpdf.exe is included in the bin directory after installation.

Joris Meys
  • 106,551
  • 31
  • 221
  • 263
  • Not sure, but I had Rtools installed and still got this note. – NelsonGon Apr 15 '19 at 09:32
  • 1
    @NelsonGon Did you install the latest version, i.e. 3.5 (it wasn't frozen yet at the time I wrote this answer). For me that solved the problem as it contains qpdf.exe. – Joris Meys Apr 16 '19 at 14:33
  • I solved this issue after several trials by navigating to SYSTEM32 in Windows and pasting the contents of qdf/bin there. I still had Rtools though. – NelsonGon Apr 16 '19 at 14:35
  • 1
    @NelsonGon That sounds like you have a problem with your PATH settings. You have to make sure that Rtools is not installed in Program Files, and that it is added to your PATH variable at the beginning. That way you don't have to start messing with your SYSTEM32 folder, because that's a can of worms you want to keep closed... (see also https://cran.r-project.org/bin/windows/Rtools/Rtools.txt ) – Joris Meys Apr 16 '19 at 15:26
  • I'm running Rtools 3.5 and still getting the same warning when checking with devtools::check(document = FALSE). Rtools installed at c:/ – Paulo E. Cardoso Feb 17 '20 at 12:49
  • @PauloE.Cardoso then check your path variable. I'm absolutely positive it works. Follow the guidelines in the accepted answer and check on the link I provided in a previous comment how to set Rtools correctly. – Joris Meys Feb 18 '20 at 10:03
  • @JorisMeys. Not working. I have RToos 3.5 installed on c:/; qpdf-9.1.1 folder copied into program files folder (x64) and a system environment variable defined to qpdf set to the qpdf.exe file on bin folder. I'm running R from RStudio. Sys.getenv("PATH") not reading the Env Var. – Paulo E. Cardoso Feb 23 '20 at 18:53
  • @PauloE.Cardoso That is not how the guidelines tell you to do it. Install RTools in C:/. Don't touch anything. Do NOT!!!!! move the qpdf folder. Don't. Leave it. I know you want to, but it is NOT in the guidelines. The bigger problem is your R installation not being able to access your OS correctly. No clue how you messed that one up, but I'd wipe everything and start anew, without touching qpdf this time. It works, tested by 420 students of mine. It works. – Joris Meys Feb 26 '20 at 14:23
  • 1
    I've solved creating an R_QPDF env var linked to the Rtools/bin/qpdf.exe installation. – Paulo E. Cardoso Mar 04 '20 at 22:01
0

After installing the latest version of RTools, the warning still popped up. However, I noticed that the Windows "where" command gave two paths to qpdf (different versions). After removing the R_QPDF environment variable and removing the new install of qpdf from the Windows path, so that only qpdf in RTools was found, the warning disappeared.

tak101
  • 41
  • 4