2022-01-26

Missing import(Rcpp) in NAMESPACE leads to C++ library error during R CMD check

Summary

I am working on an R package that uses Rcpp. I took over the project with many issues and I am trying to fix them. The problem with this is that I don't know how to create a minimal example for reproduction in this situation because the package is quite large and I was not involved in the early setup. I would appreciate suggestions on how to go about it, I am new to writing packages in R/Rcpp.

I got it into a state that it passes automated R CMD checks both on macOS and Linux in Github Actions.

There is a deprecated file named "R/simulate.R" that contains one function that is no longer used. I am trying to remove this file.

The relevant lines are:

...
#' @useDynLib mvMAPIT
#' @export
#' @import CompQuadForm
#' @import doParallel
#' @import Rcpp
#' @import RcppArmadillo
#' @import Matrix
#' @import mvtnorm
#' @import PHENIX
simulate <- function(...) {...}

I used devtools::document() to update the autogenerated files in the package.

With this, the lines

import(Matrix)
import(PHENIX)
import(Rcpp)
import(RcppArmadillo)
import(doParallel)
import(mvtnorm)

were removed from the file NAMESPACE.

After the removal, when I run R CMD check . on macOS-latest, I get the following error:

 * checking tests ... ERROR
  Running ‘testthat.R’
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(myPackage)
  >
  > test_check("myPackage")
  libc++abi: __cxa_guard_acquire detected recursive initialization

Running R CMD check . on ubuntu-20.4 gives the following error when checking tests:

Error: <rlib_error_2_0 in process_get_error_connection(self, private):
 stderr is not a pipe.>

Removal steps

  • git rm R/simulate.R
  • in R devtools::document() leads to the following changes:
     modified:   NAMESPACE
     deleted:    R/simulate.R
     deleted:    man/simulate.Rd
    
  • R CMD check . produces the above error.

What I tried

I found this issue with a similar problem and therefore tried to reinstall packages with install.packages(c('Rcpp', 'RcppArmadillo', 'httpuv'))

The issue persists.

I tried git grep -nrw "simulate" to search for the function that was defined in the file to find forgotten use of the file but nothing shows up.

Progress update

Instead of running devtools::document(), I only deleted the line export(simulate) manually from the file NAMESPACE. With this, the lines

import(Matrix)
import(PHENIX)
import(Rcpp)
import(RcppArmadillo)
import(doParallel)
import(mvtnorm)

remain in the file NAMESPACE.

These lines were autogenerated from annotations to the function that I removed by deleting R/simulate.R:

...
#' @useDynLib mvMAPIT
#' @export
#' @import CompQuadForm
#' @import doParallel
#' @import Rcpp
#' @import RcppArmadillo
#' @import Matrix
#' @import mvtnorm
#' @import PHENIX
simulate <- function(...) {...}

Now, R CMD check . runs correctly.

I guess this means I do not understand the annotations and the NAMESPACE yet and there is another dependency that requires these imports in the NAMESPACE.

If there is a problem with how I am asking the question, I would be happy to get feedback as well. I am also new to posting a question.

Thank you!



from Recent Questions - Stack Overflow https://ift.tt/3KFjwgO
https://ift.tt/eA8V8J

No comments:

Post a Comment