0

I am practicing R package writing with Rcpp, devtools, and roxygen2. However, when I run document("mypkg") under the dev mode, I got the following error:

Updating mypkg documentation
Loading mypkg
Error: file already exists: 'mypkg/src/RcppExports.cpp'

My RcppExports.cpp file is very similar to the default Rcpp.package.skeleton.

What could possibly go wrong here?

I understand I probably should provide more relevant info, but I don't really have a clue. I would be happy to put more here if anyone has any suggestion.

Best Regards,

yuez
  • 885
  • 1
  • 8
  • 16

2 Answers2

1

The message file already exists comes from this line in Rcpp

And the isSafeToOverwrite looks like this:

    // Check whether it's safe to overwrite this file (i.e. whether we
    // generated the file in the first place)
    bool isSafeToOverwrite() const {
        return existingCode_.empty() ||
               (existingCode_.find(generatorToken()) != std::string::npos);
    }

So my best guess is that something has happened to the generator token that compileAttributes puts on top of the file.

Romain Francois
  • 17,432
  • 3
  • 51
  • 77
0

Hm, "works for me" but I don't use devtools.

I would

  • start with a fresh package just so see if / where it breaks

  • make sure you are not being bitten by pre/post roxygen2 4.0 issues (there is converter script)

  • maybe try with / without devtools -- I happily use build & reload in RStudio all the time on a current (non-public) package using roxygen2 along with Rcpp

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • the naive Rcpp skeleton package works. I will investigate further and update this post. Thx – yuez May 12 '14 at 15:46