I am working on a package which I can load using devtools. But
R CMD check asm
gives me an error message
Error : package ‘seedDisp’ required by ‘asm’ could not be found
Which is kind of obvious as it is not installed in the global library.
But: I have installed installed in a local library (./library) and I have a .Rprofile file in the directory from which I run the checks as follow:
.libPaths(normalizePath("library"))
So when I run R and use devtools and load_all(.) it loads as the package seedDisp is installed.
It seems that R CMD check does ignore the library location which is set via the .Rprofile file.
So I tried
R CMD CHECK -l ./library asm_0.0.1.tar.gz
but it seems that -l only is used to install in and not to look for installed packages.
How can I tell R CMD check to look for installed packages in the library at ./library ?
One way to do this is via the R_LIBS_USER variable so I generally do
R_LIBS_USER=/some/other/path R CMD check asm_0.0.1.tar.gz
If that variable is generally set on your system, you need to do the usual trick of appending, or just set it in your shell via e.g.
export R_LIBS_USER="/some/other/path:${R_LIBS_USER}"
R CMD check asm_0.0.1.tar.gz
This mechanism is independent of how you call R CMD check it will work with or with devtools.
Related
For reasons that are too long to explain here, I must use R.2.8.1 (unfortunately). I need to have the xlsx package installed on it. Since I am on R 2.8.1, about ten years old, I can't use the latest version of xlsx but an older version, for instance xlsx_0.1.3 from 2010 seems a good choice. However the previous releases per R-CRAN policy are only available in tar.gz.
This is very unfortunate to me because I have to use RGui on windows which only accepts .Zip packages in installation. Therefore I tried the following stuff, in vain:
1-I tried to use Rcmd but I get the following error message:
C:\Program Files (x86)\R\R-2.8.1\bin>Rcmd INSTALL C:\Users\username\Downloads\xlsx_0.1.3.tar.gz
Can't use 'defined(#array)' (Maybe you should just omit the defined()?) at C:\PROGRA~2\R\R-28~1.1/bin/INSTALL line 42.
so I give up on this one.
2-Then I think that the best solution is to convert the package xlsx_0.1.3.tar.gz into a compatible xlsx_0.1.3.zip package by building it using R.2.8.1 but I can't make it. Here is one of the things I have tried so far.
I have unziped xlsx_0.1.3.tar.gz and I organized it in the following way, which brought me the furthest:
Documents\xlsx
Documents\xlsx\activate.bat
Documents\xlsx\build_xlsx.bat
Documents\xlsx\R
Documents\xlsx\R\inst
Documents\xlsx\R\man
Documents\xlsx\R\other
Documents\xlsx\R\R
Documents\xlsx\R\DESCRIPTION
Documents\xlsx\R\NAMESPACE
Documents\xlsx\R\NEWS
Documents\xlsx\R\WISHLIST
inside activate.bat, I wrote:
SET TMP=C:\Users\username\Documents\TOTO\xlsx\tmp
SET TEMP=%TMP%
SET RTOOLSPATH=C:\DEV_307\toto\Rtools
SET RPATH=C:\DEV\toto\R\R-2.8.1
SET PATH=%RTOOLSPATH%\bin;%RTOOLSPATH%\MinGW\bin;%RPATH%\bin;%PATH%
inside build_xlsx.bat, I wrote:
R CMD BUILD R
R CMD check --no-examples --no-tests R
R CMD build --docs=normal --binary R
Then I still get:
C:\Users\username\Documents\TOTO\xlsx>R CMD BUILD R
* checking for file 'R/DESCRIPTION' ... OK
* preparing 'R':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
Can't use 'defined(#array)' (Maybe you should just omit the defined()?) at C:\DEV\toto\R\R-2.8.1/bin/INSTALL line 42.
ERROR
Installation failed.
Removing 'C:/Users/username/Documents/Rinst1210839349'
Thank you for your help
I can't include structured content in comments. This is really a comment.
The structure of source packages (which is what you have with xlsx_0.1.3.tar.gz if you pulled it from the CRAN archives) hasn't changed (much) since 2.8.1.
You'll also need to grab rJava_0.8-3.tar.gz and xlsxjars_0.2.0.tar.gz from the archive as xlsxjars + xlsx rely on rJava.
Extract each (since Windows R 2.8.1 seems to not grok gz files). They should make rJava, xlsxjars and xlsx directories each.
Move to the parent directory of both.
Run:
R CMD javareconf
R CMD build rJava
R CMD INSTALL rJava_0.8-3.zip # I believe this will be the name
R CMD build xlsxjars
R CMD INSTALL xlsxjars_0.2.0.zip
R CMD build xlsx
R CMD INSTALL xlsx_0.1.3.zip
and you should be gtg.
If there is any option I can set to R CMD INSTALL to remove all installed libs ( under package installation directory) before a new installation?
I tried
R CMD install -c --preclean
But it does not work. Should I create a clean config?
PS : I am under windows.
EDIT more context:
I am developing a package. I generate the lib automatically at each build. So I need to remove the old ones each time I have a modification. Removing the entire library is Ok for me also.
I know this is old, but I just ran into this myself. I am assuming here by "installed libs" you mean libraries internal to your package on which your package depends. (In my case, it is libzip and libzippp that I am cleaning up.)
My solution was here: https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Configure-and-cleanup
Under a Unix-alike only, an executable (Bourne shell) script cleanup is executed as the last thing by R CMD INSTALL if option --clean was given, and by R CMD build when preparing the package for building from its source.
I created a file named "cleanup" that is a Bash script and change directories, call make distclean and remove so and o files there. This is called at the beginning and the end of the build/install process. The cleanup script is called from within the package directory.
The DESCRIPTION file in R packages has several ways of specifying dependencies, e.g. Depends, Suggests and Imports. Which one should I use to specify a dependency that is optional once the package is installed, but required for running R CMD check?
In my particular case I am using testthat to run some tests automatically when R CMD check is run, but during "normal" operation, testthat is not required. The answer to this question suggests that testthat should be in Suggests, but is that enough to ensure that R CMD check runs correctly?
What I would like to see, if it exists, is a field where I can speciy dependencies that are required only to run R CMD check, which should fail with an appropriate error message if these packages are not available.
Yes, you should put them in the Suggests field. The only other thing required for R CMD check to run successfully is to ensure the packages in the Suggests field are installed in a location that will be found by R CMD check.
If they're not available, you can set the environment variable _R_CHECK_FORCE_SUGGESTS=false and R CMD check will run, with a "NOTE" about the missing suggested packages.
According to the document Writing R Extensions ss 1.3 "R CMD check and R CMD build run R with --vanilla, so none of the user's startup files are read".
This doesn't seem to happen on my installation. I have found that my version of R (2.15.1 on Mac) loads the packages in my .Rprofile - i am pretty sure about this, as i've managed to reliably break it by adding library(hobblegobble) to my .Rprofile.
does this matter? If so, should i always prefer to build packages with
R --vanilla CMD build
thanks
You can use either R --vanilla CMD build myPackage or R --vanilla CMD INSTALL --build myPackage if your .Rprofile loads packages that you are trying to build (or install).
The only drawback I am aware of to using --vanilla is that the terminal's completion (i.e. having the package directory name completed for you when you tap tab) may not work while you're typing the path to the package directory.
However, a better solution may be to wrap if (interactive()) {} around code in your .Rprofile that you only want to be run in interactive sessions. e.g. library or require calls.
In your case if your .Rprofile had if (interactive()) library(hobblegobble) you wouldn't need to use --vanilla.
I'm working on a script that creates a package in the current directory (using pdInfoBuilder from BioConductor), and I'd like to install it while the script is running. install.packages() with repo=NULL seems like an obvious choice, but this seems to only except package directories tarballed and gzipped. Is there a way I can override this, since the create.pkg() function doesn't create a *.tar.gz? Currently I am using:
R CMD INSTALL package.name
Thanks,
Vince
If it's a source file, then use install.packages() and set the repos=NULL:
install.packages(file_name_and_path, repos = NULL, type="source")
See this related question: How do I install an R package from source?
If it isn't a .tgz, is it in full directory form? All you have to do is R CMD INSTALL dirname and it'll work. The install.packages() function's only real advantage over a raw R CMD INSTALL is that it will do all the downloading, dependency matching, etc for you.