R CMD check --as-cran warning - r

I am trying to do R CMD check before uploading my package to CRAN.
R CMD check --as-cran "my package folder".
However, it spits out this warning:
"checking for unstated dependencies in examples ... OK
WARNING
pdf is needed for checks on size reduction of PDFs"
I searched online but found no clue to solve this problem. This warning does not turn up when I run "R CMD check" only. And my package works with no problem. Could someone please tell me what might be wrong with my package?

qpdf is an external program necessary to reduce the size of pdf, it can be downloaded from the sourceforge site. You can install either the 32 bis or 64 bits version, both are working.
To install it, you download the file, and then copy the folder to your program folder.
Next you need to edit you system path to point to the bin folder by adding 'C:\Program Files\qpdf-version_numer\bin'. In a command batch (cmd) type qpdf to see if that has been set correctly, you should get the message
qpdf: an input file name is required
Usage: qpdf [options] infile outfile
For detailed help, run qpdf --help
Once this is done, the warning should be removed from your R CMD check

To add to Cedric's answer:
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_no\bin to your system PATH under the environment variables, and re-launched R so it picks up the new PATH, you need to convince Windows 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. Once you've done this, Windows will recognize the file as safe to run and allow other programs, including R, to use it.

Related

How do I configure Rtools40 in Windows 10 with R 4.0.0?

I recently installed R 4.0.0. Along with it, I also installed Rtools40. The CRAN website said I also need to specify path for Rtools make file in the .Renviron file. But when I created the .Renviron file, I cannot use stats package. If .Renviron file exists, it gives error that some shared dll file is missing. And if I delete the .Renviron file, this error goes away, but I cannot compile packages using Rtools40. How can I configure this .Renviron file so that I can also use both - Rtools40 and stats package?
My Rtools make file is in C:/(MyUserName)/Rtools40/usr/bin folder. This same folder also contains the bash file, which came with Rtools40.
writeLines('PATH="${PATH};${RTOOLS40_HOME}\\usr\\bin"', con = "~/.Renviron")
I had the same problem. I was following the Rtools40 download instructions, and instead of adding Rtools to the beginning of the path, adding it to the end fixed it.
I have been always using a folder "C:\s" to deploy the always changing versions of R related software friends. I recently installed Rtools40 to "C:\s\rtools40" and linking it with my R-4.0-1 was straightforward to me. I just went to "C:\s\R-4.0.1\etc\x64", edited the "Makeconf" file using WordPad, and replaced the line
RTOOLS40_HOME ?= c:/rtools40
With
RTOOLS40_HOME ?= c:/s/rtools40
Then I did the same for "C:\s\R-4.0.1\etc\x32". After these, I installed a package using RStudio (running install.packages("jsonlite", type = "source") in the R-4.0.1 console), and no warning related to Rtools was displayed in the console. I hope this works well in your machine.

Rtools is not being detected from RStudio

I am using latest R, RStudio and Rtools.
-- I have updated the environment variables. Now I can call gcc, or R from command line.
While I was trying to publish an app from the RStudio, I get the following error,
Preparing to deploy application...DONE Uploading bundle for
application: 64015...Error:
* Application depends on package "Rtools" but it is not installed. Please resolve before continuing. Execution halted
-- I have tried this,On Console,
> find_rtools(T)
Scanning path...
ls : D:\Rtools\bin\ls.exe
gcc: D:\Rtools\GCC-46~1.3\bin\gcc.exe
VERSION.txt
Rtools version 3.3.0.1959
Version: 3.3
[1] TRUE
So, Rtools seems basically there!
-- I have checked environment variables, those are OK, as I also mentioned R and gcc can be started from command line
Yet, I tried to install and check from within RStudio using installr package, it says,
> install.Rtools()
No need to install Rtools - You've got the relevant version of Rtools installed
>
-- This is not a possible duplication of this, Rtools not being detected by R
I have tried all these. Did not work.
Please suggest a solution. Thank you very much for your time.
I have no idea why RStudio has such kind of problems from time to time but there is a manual work-around described here:
https://github.com/rwinlib/r-base/wiki/Testing-Packages-with-Experimental-R-Devel-Build-for-Windows
Basically you have to set two environment variables to point to the correct installation path of Rtools:
Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")
To avoid losing this change after restarting RStudio you could modify your (Windows) environment variables instead or add the following rows to your .Renviron file that is executed at each startup of R.
BTW: The $(WIN) part is no typo but required so that R can inject "32" or "64" depending on the R version you are using (32 or 64 bit).
Edit 1: See also this r-bloggers article published recently: https://www.r-bloggers.com/quirks-about-running-rcpp-on-windows-through-rstudio/
Note that there are new potential kinds of problems (from R 3.3 onwards), since R (not RStudio, but R) adds a BINPREF variable and modifies the Path variable by default, see the Renviron.site file for the latter, on Windows typically e.g. under C:\Program Files\R\R-3.4.3\etc:
PATH="C:\Rtools\bin;${PATH}"
This might easily conflict for people with a custom path and/or multiple versions of Rtools installed, so I have commented this out with a #.
For the BINPREF problem, see the Makeconf file, e.g. under C:\Program Files\R\R-3.4.3\etc\x64:
BINPREF ?= c:/Rtools/mingw_64/bin/
I have then modified this to c:/Rtools34/mingw_64/bin/, which is where I have installed my Rtools34.
You can do the same for the Makeconf file under the 32-bit arch. sub-directory.
Via R CMD check not looking for gcc in Rtools directory:
R uses a BINPREF variable to locate certain executables, including components of RTools.
BINPREF can be set in a number of places. In my case, it was set in C:/Users/MYUSERNAME/Documents/.R/Makevars. Deleting the contents of this file removed a link to a previous, and since deleted, installation of RTools.
It is also worth checking the file $RPATH/etc/i386/Makeconf (swap i386 for x64 if you have a 64-bit installation), which will be re-created with each new installation of R. Note the line
BINPREF ?= c:/Rtools/mingw_32/bin/, which (via the ?= operator) will set the value of BINPREF if it is not already set, as it was in the Makevars file mentioned above.
A temporary fix is to replace BINPREF ?= with BINPREF =,
but as the Makeconf file is overwritten when R is updated, you'll have to remember to do this each time. Better to edit, or delete, the Makevars file for a permanent change.
After searching a lot solutions, finally I delete .Renviron file in C:\Users\My name\Documents. Then rtools40 works.

Error installing and running rcpp

I'm pretty new to R so apologies for a stupid question. I'm trying to get rcpp running but I'm stuck in an endless loop of R asking me to re-install RTools.
I broadly followed the code in this blog post, although first time off I installed everything by hand & I've subsequently re-installed everything a few times over. I'm running Windows 7, R version 3.1.2, R Studio Version 0.98.1091 (not that this should matter much) and RTools 3.1.
An edited highlight of what my console looks like is as follows:
> library(installr)
Welcome to installr version 0.15.3...
> install.Rtools()
Loading required package: devtools
No need to install Rtools - You've got the relevant version of Rtools installed
> find_rtools()
[1] TRUE
> library(Rcpp)
> evalCpp("1+1")
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 65535 occurred building shared library.
At which point a dialog box pops up saying:
Install Build Tools
Compiling C/C++ code for R requires installation of additional build tools.
Do you want to install the additional tools now?
And then I get directed to download and re-install RTools 3.1 from cran all over again.
I've seen that this can be an issue with the PATH variable but I've tried various things including:
Nothing (extra) in the PATH variable
Including both references to R (C:\Program Files\R\R-3.1.2\bin\x64) and RTools (C:\RBuildTools\3.1\bin;C:\RBuildTools\3.1\gcc-4.6.3\bin;) in the PATH. Once with RTools first, once with R first
Including just a reference to RTools in the PATH as the initial install file directed me to do.
Any ideas on things to try would be gratefully accepted!
EDIT
Following Dirk's comment it looks like I might have a problem with how RTools is installed. I've followed the instructions from several blogs / tutorials on how to install RTools; all to no avail (yet!)
This GitHub page gives some instructions on how install and check that the installation has worked. I've followed all the checks (see below for copy of the console) and it looks like I have a working install of RTools, but when I try to run evalCPP() again I get the same error as before directing me to install RTools.
> Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-3.1.2\\bin\\x64;C:\\RTools\\bin;C:\\RTools\\gcc-4.6.3\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Enterprise Vault\\EVClient\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\PrivateAssemblies\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\;C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\"
Warning message:
printing of extremely long output is truncated
> system('g++ -v')
Using built-in specs.
COLLECT_GCC=C:\RTools\GCC-46~1.3\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/rtools/gcc-46~1.3/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpc=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --disable-shared --enable-static --enable-targets=all --enable-languages=c,c++,fortran --enable-libgomp --enable-sjlj-exceptions --enable-fully-dynamic-string --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror CFLAGS='-O2 -mtune=core2 -fomit-frame-pointer' LDFLAGS=
Thread model: win32
gcc version 4.6.3 20111208 (prerelease) (GCC)
> system('where make')
C:\Rtools\bin\make.exe
I've also had a look at Appendix D of R Installation and Admin. I can't see anything in here I've not already tried except for section D.4 which implies I might need to rebuild rcpp from source using my installed RTools. I don't have time to do this right away but will give it a try unless people say this route is not worth my time.
EDIT v2
So I tried building rcpp from source ... and that didn't work either. I downloaded both the package source and windows binaries from the CRAN Rcpp package page. In the R console I now get:
> install.packages(pkgs = "C:/Rcpp_0.11.4.tar.gz", repos = NULL, contriburl = NULL, type = "source", verbose = TRUE)
Installing package into ‘C:/Users/james.macadie/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
system (cmd0): C:/PROGRA~1/R/R-31~1.2/bin/x64/R CMD INSTALL
Warning in install.packages :
package ‘C:/Rcpp_0.11.4.tar.gz’ is not available (for R version 3.1.2)
I guess my active questions now boil down to:
Reading the whole of the post above can anyone tell me how to fix things so it just works? Or, failing that...
What tests can I run to check I really do have Rtools installed correctly? Everything I have found on the internet suggests I do: system('where make') etc. However, the evidence of being unable to run evalCpp or other rccp functions suggests I don't.
What am I doing wrong when building from source? Should I try the command line option?
EDIT v3
Running evalCpp with showOutput= TRUE and verbose = TRUE I think I've tracked the error back to R CMD SHLIB not working. I followed this blog, which shows how to work with the command line R directly. However when I get to the line R CMD SHLIB sequence_examples.c the execution just skips straight to the next command line without doing anything, generating any files in the directory or throwing any errors. I tried running the --help options at the command line but get the same sort of error:
C:\Users\james.macadie> R --help
Or: R CMD command args
where 'command' is one of:
INSTALL Install add-on packages
REMOVE Remove add-on packages
SHLIB Make a DLL for use with dynload
BATCH Run R in batch mode
build Build add-on packages
check Check add-on packages
Rprof Post process R profiling files
Rdconv Convert Rd format to various other formats
Rdiff difference R output files
Rd2pdf Convert Rd format to PDF
Rd2txt Convert Rd format to pretty text
Stangle Extract S/R code from vignette
Sweave Process vignette documentation
config Obtain configuration information about R
open Open a file via Windows file associations
texify Process a latex file
Use
R CMD command --help
for usage information for each command.
C:\Users\james.macadie> R CMD SHLIB --help
C:\Users\james.macadie>
N.B. for people reading the earlier code samples higher up this post I have changed a few things since those code snapshots:
I've installed R directly into C:\R. It used to be in C:\Program Files\R\ but as has been suggested file paths with spaces in can cause problems
I'm referencing Rtools under C:\Rtools\ and not C:\RBuildTools\
Thanks for any suggestions, as ever
Had the same endless loop issue when trying to install Twitter's BreakoutDetection (which is also written in cpp)
fixed by executing the following
Sys.setenv(PATH="%PATH%;C:/Rtools/gcc-4.6.3/bin;c:/Rtools/bin")
and then answering "no" when presented with the following prompt:
"Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?"
Didn't try these actions independently so not sure if either on their own would have fixed the issue
I found that ensuring all of these were in my path fixed it. I did this with RStudio closed; I didn't reboot after.
C:\Program Files\R\R-3.1.3\bin\x64
C:\Program Files\R\R-3.1.3\bin
C:\RBuildTools\3.2\bin
C:\RBuildTools\3.2\gcc-4.6.3\bin64
C:\RBuildTools\3.2\gcc-4.6.3\bin
C:\RBuildTools\3.2\gcc-4.6.3\i686-w64-mingw32\bin
These are on my Win7-64bit computer. YMMV, and I'm mostly posting this to ensure others see it if they are having the same issue.
In the end it was something a bit left-field. Inspired by the following post, I had a look at the ComSpec environment variable. Not quite sure how, but I had it set to "cmd.exe".
Removing the double quotes, so it said cmd.exe, and then rebooting fixed everything.
Thanks to all who've tried to help.
I experienced the same problem, I fixed this problem by adding Rtools dir into env variables:
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")

Rcpp can't find Rtools: "Error 1 occurred building shared library"

I am running into a simple setup problem with Rcpp and I cannot get it to work. I tried to follow this example http://www.r-bloggers.com/user2013-the-rcpp-tutorial/
But when executing this code:
library(Rcpp)
evalCpp("1 + 1", showOutput= TRUE)
I get this output
C:/R/R-30~1.1/bin/x64/R CMD SHLIB -o "sourceCpp_33280.dll" "file8d01b0a675b.cpp"
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
WARNING: Rtools is required to build R packages but is not currently installed.
Please download and install the appropriate version of Rtools before proceeding:
I have done the following things in an attempt to make it work:
installed Rtools 31 with install.Rtools()
installed R in C:\R\R-3.0.1
library files are stored in C:\R\R-3.0.1\library
installed Rstudio in C:\R\RStudio
placed my script in C:\R
most similar issues seem to suggest that a space was in the file path, therefore i moved pretty much everything I could. But still it fails to locate Rtools. I tried it on my laptop and on my desktop and both don't work, so there is probably something structural I am doing wrong.
Looks like neither your R binaries nor Rtools directories are in your system's PATH environment variable. Try this:
> writeLines(strsplit(Sys.getenv("PATH"), ";")[[1L]])
C:\R\Rtools\bin
C:\R\Rtools\gcc-4.6.3\bin
C:\R\R-devel\bin\x64
[... and so on ...]
If your directories C:\R\R-3.0.1\bin\x64\ and C:\R\Rtools\bin\ & C:\R\Rtools\gcc-*.*.*\bin\ (replace \gcc-*-*-*\ with your version of the gcc-binaries) are not listed, the needed components can't be found.
To be on the safe side, also create a system variable called CYGWIN with the value nodosfilewarning.
After changing/creating the PATH and CYGWIN variables, reboot. Then it should work and you can place your sources anywhere on your machine and also compile them manually using R CMD SHLIB.

qpdf.exe for compactPDF?

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?
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 ...
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.
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.
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.
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.

Resources