[Rcpp-devel] devtools::load_all() working differently for Rcpp >= 0.11.0

Finlay Scott drfinlayscott at gmail.com
Thu Jul 3 11:27:29 CEST 2014


Hi,

First of all, thanks for all the hard work that has been put into Rcpp. It
really is a great package.

I'm redeveloping a package I was working on last year that uses Rcpp,
particularly attributes. I used the devtools package to help with the
development process. My general development approach was to add or change a
function with attributes in the C++ source code, and then reload the
package using the devtools function load_all(). This would recompile the
source code, and update the RcppExports.R and .cpp files as necessary. The
new exported function would then be immediately available to the current R
session.

I have now updated all my R packages and am using Rcpp 0.11.2.
Unfortunately, the behaviour of load_all() is now different. For example,
if I start a new package from scratch:

library(Rcpp)
Rcpp.package.skeleton("NewPackage", attributes = TRUE)

# Then load devtools and use load_all()

library(devtools)
load_all("NewPackage")

# The demo function works just fine

rcpp_hello_world()

# I make a change to the source code of the rcpp_hello_world() function
# For example, changing one of the values in the returned list
# I rerun load_all()

load_all("NewPackage")

# The package recompiles, and I can see that the resulting *.o and *.so
have been updated.
# However, calling rcpp_hello_world() still returns the old output, i.e.
the function called from R does not seem to have been updated.
# Similarly, if I add a new simple function with attributes to
rcpp_hello_world.cpp
# For example:

// [[Rcpp::export]]
int do_nothing(){
    return 0;
}

# If I call load_all() again, the package compiles and the RcppExports.R
and .cpp files have been updated to include this new function (i.e. it
looks like compileAttributes() has been called by load_all()).
# However, if I try to call do_nothing() from R I get:

Error in .Call("NewPackage_do_nothing", PACKAGE = "NewPackage") :
  "NewPackage_do_nothing" not available for .Call() for package "NewPackage"

So it looks like load_all() is updating and recompiling the package
accordingly, but it is not being 'reloaded' in the current R session.

I ran a test using Rcpp 0.10.6 and the latest devtools (1.5) and the above
tests passed (i.e. after running load_all() the new function was available
to the current R session), so the problem seems to be with Rcpp > 0.11.0

Does anyone else have experience of this, and a workaround?

Apologies if this is more of a devtools question than an Rcpp one. I will
repost at the devtools mailing list if necessary.

I am using Ubuntu 14.04 , R 3.1.0; x86_64, devtools 1.5

Thanks

Finlay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140703/1e6d5566/attachment.html>


More information about the Rcpp-devel mailing list