Travis CI R package error in documentation - r

Greetings and Salutations,
I recently hooked up a github repo containing an R package to Travis CI. I thought the repository would be built fine, however, there are several check errors that arise which I cannot replicate on local installs of Windows, OS X, or Ubuntu 14.04 LTS.
The errors are originating off of functions that share the following in common:
Have roxygen2 help documentation that is coded with the #keyword internal.
Are written using Rcpp / RcppArmadillo.
Specifically, I receive the following warning from Travis CI:
Functions or methods with usage in documentation object 'internal
function here' but not in code:
This is not particularly problematic as it is a warning. A previous post addressed a different form of this example using #method and #export. However, the Rcpp functions are not of an OO class (S3/S4/RR).
However, when Travis CI starts to evaluate the package's examples, this warning then becomes an error:
Error: could not find function "internal function here"
and causes the build to fail. Though, the build itself should pass the check since the function does exist.
Travis CI is configured using the recommended guidelines in the following manner:
language: r
sudo: required
warnings_are_errors: true
r_packages:
- ggplot2
- devtools
- RcppArmadillo
- knitr
- gridExtra
- grid
r_build_args: "--no-build-vignettes"
r_check_args: "--no-build-vignettes --as-cran"
Note The --no-build-vignettes was added since Travis would error upon building them since the R code calls one of the internal functions listed in the docs.
Here is I believe the latest public facing build:
Travis CI report (v1.0.1)
And the results from the first version on CRAN:
CRAN report (v1.0.0)
Any thoughts would be welcome.

I can replicate the warnings/errors on my laptop (running OS X). I'm also pretty sure that if you check out your repository, build the tar ball and then run R CMD check on it, you will get the same warnings/errors as on Travis CI. (I'm assuming you only checked your package from within R Studio.)
As far as I can tell, the problem is that you added R/RcppExports.R and src/RcppExports.cpp to your .gitignore, which means these files are not on GitHub. Travis CI does not run Rcpp::compileAttributes for you.
There are two simple solutions:
Remove R/RcppExports.R and src/RcppExports.cpp from .gitignore and commit them to GitHub with everything else. That sort of makes sense, because those files are in fact part of your package and you should not necessarily expect an end-user to compile them before installing your package. I think this is the proper way to deal with this.
Add a line to your travis.yml to run Rcpp::compileAttributes before building the package, e.g. Rscript -e "Rcpp::compileAttributes()".

Related

Cannot install any package in Julia

I had used Julia some months back for a project, and didn't use it since. I hadn't faced problems back then. But now, I absolutely am not able to install any package.
(#v1.5) pkg> add Distributions
Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Distributions [31c24e10]:
Distributions [31c24e10] log:
├─Distributions [31c24e10] has no known versions!
└─restricted to versions * by an explicit requirement — no versions left
Any package I install, I am getting the same error. How do I fix it?
This is the status of Pkg:
(#v1.5) pkg> status
Status `C:\Users\jaine\.julia\environments\v1.5\Project.toml`
[6e4b80f9] BenchmarkTools v0.5.0
[7073ff75] IJulia v1.21.2
[91a5bcdd] Plots v1.6.0
[438e738f] PyCall v1.91.4
[d330b81b] PyPlot v2.9.0
[2913bbd2] StatsBase v0.33.0
Given
├─Distributions [31c24e10] has no known versions!
it looks like you have a missing or corrupt package registry. The package manager will reinstall it for you if you delete .julia/registries and try to add the package again.
You can do this from within julia
rm(joinpath(homedir(), ".julia", "registries"), recursive=true, force=true)
These are indeed some of the more tricky situations to resolve so please bear with me as we work through this.
If you are not familiar with the basics of the package manager, it's worth a quick read to check out: https://julialang.github.io/Pkg.jl/v1/getting-started/
Assuming you are now in the Julia Repl, my general work flow for these issues is to remove everything it warns me about. The core problem here is that one of your existing packages is saying it needs a specific version of Distributions.jl but it's not able to add it. So, the first step would be to enter the pkg manager by doing ] and type rm Distributions.
Then, while still in the pkg mode, do resolve and add Distributions.
So the process is to just remove each package the Repl complains about until it stops complaining.
Note: If you run into something like this again, the worst-case scenario is to remove the project and manifest files for the specific Julia version you are using. If you navigate to ".julia/environments" you should be able to completely reset the Julia Env for a specific version there (that way you don't need to actually reinstall Julia).

How can I test a change on a forked R package before sending a pull request?

I have forked and cloned an R repository on my local computer. I have made some edits but I'm not sure how to test these changes before sending out a pull request.
I don't know how to make an R package from this clone one and test it.
The usual two-step:
R CMD build directoryOfYourPackage
resulting in a tar.gz archive you use in the next step:
R CMD check package_1.2.3.tar.gz
where package and the version are determined by the DESCRIPTION file.
Both commands have options, i.e. you can suppress vignette creation and test if you have an insufficient LaTeX installation and these pdf vignettes etc pp. See Writing R Extensions for all the gory details.
Also, if you are set up for Travis CI and the package is then your commit back to your fork should trigger a build at Travis doing the same: package building and check. However, it is also a good idea to check locally before committing...

Error using Travis CI with R package: 'roxygen2' >= 5.0.0 must be installed for this functionality

I am trying to use Travis CI with an R package (specifically this in-development package here).
When I update a repository, I get the following message (see the logs here):
Error: processing vignette 'comparing-mclust-and-mplus-output.Rmd' failed with diagnostics:
'roxygen2' >= 5.0.0 must be installed for this functionality.
Execution halted
This is consistent across two different packages--although the version of roxygen2 that I have is 6.0.1. I haven't been able to find others with this particular issue on either Stack Overflow or the roxygen2 GitHub page. I used usethis::use_travis() to set up the package for use with Travis (i.e., add travis.yml file.
Any ideas about how to address this?
So I believe the problem you have is with your DESCRIPTION file. Travis will install all package dependencies before trying to build the package / vignettes, so the version you have installed locally is of no consequence.
Rather, you need to be sure that roxygen2 is a dependency of your package (probably only needed in Suggests if it is necessary to build but not use your package). So adding:
Suggests:
roxygen2
To your DESCRIPTION file should fix the issue!

Why does building an R package stop my code from working?

It seams that upon installing my custom R package code stops to work? Why?
In detail, I have a tiny R package goEnrichment (click to see the Github repo). The R package includes just just two functions and some binary data.
Also there are two test R-scripts that I run after installing the R package with R CMD INSTALL goEnrichment. One test script fails while the other works.
The only difference between the two scripts is that in the working version I require the necessary libraries and source the functions file manually, while in the other failing script I require my goEnrichment library directly.
Note, that both scripts are started directly from their directory goEnrichment/exec.
Start the working test with cd goEnrichment/exec && Rscript testGoEnrichment_works.R. Excerpt:
# This is the WORKING version
require(GOstats)
require(GSEABase)
require(RMySQL)
source( "../R/goEnrichment.R" )
Start the failing test script with cd goEnrichment/exec && Rscript testGoEnrichment_fail.R. Excerpt:
# This version FAILS
require(goEnrichment)
The error I get is somewhat uninformative to me:
'dimnames' applied to non-array.
The built R package fails on two platforms, that is on Debian Wheezy 64 with R 3.0.2 and on Mac OS X Yosemite with R 3.1.1.
I really have no clue why this happens. I checked for file format and unexpected characters using Vim. The cause does not seem to be the DESCRIPTION file either, because all libraries, goEnrichment depends on, are imported.
Does any one have a clue what causes this very weird error? Help will be much appreciated.
After much testing I found the source of the problem.
For some reason when requiring my package with
require(goEnrichment)
the generic function
summary.GOHyperGResult
is not loaded, as it should be. The method however is available when the packages, goEnrichment depends upon, are required manually. As to why this is, I had no time to investigate. I believe the here reported error is related to this bug.
Thanks to Tyler for your efforts, very much!

R 3.0.1 package build warning

I'm building R packages in R 3.0.1 on a Windows machine, using Rtools30 and the 'Build' tools associated with RStudio, which I assume is tied in with devtools (which is up-to-date). My typical process to build a package is:
Load All
Reoxygenize
Build & Reload
Check
Build Source Package
If everything goes without errors or warnings, I then:
install.packages("foo.tar.gz", repos=NULL, type="source")
Since upgrading to R 3.0.1, I now get this warning:
Warning in install.packages :
foo.tar.gz is not available (for R version 3.0.1)
I also tried before installing, and it did not get rid of the warning:
options(install.packages.check.source = FALSE)
Also, I notice this warning when I open the devtools library:
WARNING: Rtools 3.0 found on the path at c:/Rtools is not compatible with R 3.0.1.
Which is weird, Rtools 3.0 is suppose to be good from R >2.15.1 to R 3.0.x
Any ideas what is going on?
This is RStudio specific, as they wrap and/or changed a lot of functions from the utils for better integration. The problem lies with a call to getDependencies() to check for dependencies. But that function will also check whether the original package exists on CRAN and throws the given warning when it doesn't. A package you just built on your own computer is obviously not on CRAN, hence the warning.
In the source of the native install.packages(), getDependencies() isn't called in case you build from source or install from a different repository respectively. RStudio on the other hand calls getDependencies() before it passes everything on to the native install.packages() function.
This has to my knowledge no further effects, apart from confusing people. I didn't find a way to conveniently get rid of this in RStudio, as suppressWarnings() doesn't work in this context due to the complex way RStudio deals with this.
In a basic R console, you shouldn't have any problem.
So for the time being, I'd just ignore this and hope the RStudio team finds time to take care of this minor glitch.

Resources