HISKP-LQCD/hadron

Travis CI build fails yet again

martin-ueding opened this issue · 2 comments

So we have yet another failure to build on Travis CI. We see the following fail while trying to build the NAMESPACE file:

$ Rscript -e 'devtools::document();'
Updating hadron documentation
First time using roxygen2. Upgrading automatically...
Updating roxygen version in /home/travis/build/HISKP-LQCD/hadron/DESCRIPTION
Loading hadron
Error in Rcpp::compileAttributes(path) : 
  pkgdir must refer to the directory containing an R package
Calls: <Anonymous> ... update_registration -> compile_rcpp_attributes -> <Anonymous>
Execution halted

The error comes from Rcpp. I checked out the source and this is the culprit (omitted some lines):

compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
    # verify this is a package and read the DESCRIPTION to get it's name
    pkgdir <- normalizePath(pkgdir, winslash = "/")
    descFile <- file.path(pkgdir,"DESCRIPTION")
    if (!file.exists(descFile))
        stop("pkgdir must refer to the directory containing an R package")

    # check the NAMESPACE file to see if dynamic registration is enabled
    namespaceFile <- file.path(pkgdir, "NAMESPACE")
    if (!file.exists(namespaceFile))
        stop("pkgdir must refer to the directory containing an R package")

So Rcpp::compileAttributes() only works when there is a NAMESPACE present and devtools::document() calls Rcpp::compileAttributes() before building the namespace. At present, this is a circular dependency and that sucks.

On my laptop, however, I can do a git clean -xdf and that also removes the NAMESPACE file. Then running Roxygen works just fine:

> devtools::document()
Updating hadron documentation
First time using roxygen2. Upgrading automatically...
Writing NAMESPACE
Loading hadron
Re-compiling hadron

I am not sure why the Travis CI variant does not properly work.

The files that are present on the Travis CI checkout are the following:

$ ls
check		 hadron.Rproj  test
configure	 hooks	       test_bootstrap_nlsfit.Rmd
configure.ac	 inst	       test_readbinarysamples.Rmd
CONTRIBUTING.md  install       tests
data		 notes	       verify-exports
DESCRIPTION	 R	       vignettes
document	 README.md     Weighted_Model.nb
exec		 src

On Travis CI we use roxygen2 in the version 7.1.0, on my laptop ot is just 7.0.2. I will try upgrading it to reproduce the error locally.

So I've updated all the R packages locally and it fails on my laptop as well. Awesome, so I need to find a way to break this circular dependency. Guess we are the only ones who use Roxygen and Rcpp at the same time 🤷‍♂️

I just create the NAMESPACE file if it is missing before running devtools::document(). Now it works again. One could theoretically file a bug with Roxygen.