Skip to content

Chicken-and-egg NAMESPACE problem with Roxygen2, devtools::check(), and Rcpp #1599

@dbaston

Description

@dbaston

Running devtools::check() on a project that uses Rcpp fails if the NAMESPACE file does not exist:

> devtools::check()
Updating wsim.lsm documentation
Loading wsim.lsm
Error in Rcpp::compileAttributes() : 
  pkgdir must refer to the directory containing an R package

To generate the NAMESPACE file, I need to run devtools::document(). But this also invokes Rcpp, which in turn fails because the NAMESPACE file does not exist:

> devtools::document()
Updating wsim.lsm documentation
Loading wsim.lsm
Error in Rcpp::compileAttributes() : 
  pkgdir must refer to the directory containing an R package

It's not enough to run touch NAMESPACE before build, because Roxygen2 will only replace a NAMESPACE file that it generated. For now, I papered this over with a hackish Makefile:

NAMESPACE:
	echo "# Generated by roxygen2: do not edit by hand" > NAMESPACE

check: NAMESPACE
	Rscript -e "devtools::check()"

But I wonder if devtools could take care of this somehow? Since NAMESPACE is autogenerated by Roxygen2, I don't want to commit it to the repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions