Skip to content

[R-pkg-devel] nativeRoutines error when using roxygen2 in RStudio

13 messages · Georgi Boshnakov, Guido Kraemer, Rampal S. Etienne +3 more

#
Since a few weeks (after updating R-devel and Rtools) I get the 
following error when trying to build a package or document it, when 
using roxygen2 in RStudio:

In R CMD INSTALL Error in nativeRoutines[[lib]] <- routines : object 
'nativeRoutines' not found Calls: suppressPackageStartupMessages ... 
withCallingHandlers -> <Anonymous> -> load_all -> load_dll Execution halted

When I disable roxygen2, I do not get this error, but of course the 
documentation is not created.

I have installed the latest versions of RStudio, Rtools, R-devel, 
roxygen2, pkgload, but the problem persists.

Does anybody have a clue what is causing this? I am using Windows 10, 
and the package contains Fortran code.

Kind regards,
Rampal Etienne
#
Try installing the latest development version of roxygen2, if you are not using it already.
There was a bug in the released version preventing installation in some cases. 
If you don't want to use development version of roxygen2,
try putting all filenames in the Collate field in DESCRIPTION on one line and make sure that there is a single space
between them. This should work if your problem is what I think.

By the way, in such cases you will get more informative messages if you run devtools::check(). 

--
Georgi Boshnakov
4 days later
#
Dear Georgi,

Thanks for your suggestions. I have tried to install the development 
version of roxygen2, but to no avail.

I don't have a Collate field in DESCRIPTION.

devtools::check() gives me:

Updating secsse documentation Loading secsse Registered S3 method 
overwritten by 'dplyr': method from as.data.frame.tbl_df tibble 
Registered S3 method overwritten by 'geiger': method from 
unique.multiPhylo ape Error in nativeRoutines[[lib]] <- routines : 
object 'nativeRoutines' not found


Any other suggestions?

Cheers, Rampal
On 02-Nov-18 08:33, Georgi Boshnakov wrote:

  
  
#
Dear Rampal:

What version of R are you using? I had this bug appearing a while a go 
on r-devel on travis 
(https://stackoverflow.com/questions/52532026/r-object-nativeroutines-not-found/52924244#52924244), 
it disappeared after a while.

Cheers,

Guido
On 11/6/18 9:27 PM, Rampal Etienne wrote:
#
Hi Guido,

I am using the latest version of R-devel (on Windows). I've been having 
these problems since I updated R-devel mid-October (my previous version 
was a few months old). I have been updating R-devel since then, hoping 
that the problem would be disappear, but it is still there.

Cheers, Rampal
On 06-Nov-18 22:13, Guido Kraemer wrote:
#
On 06/11/2018 3:27 PM, Rampal Etienne wrote:
Do you get that error if you run "R CMD check" on the tarball of your 
package?

If so, how comfortable are you with debugging R code?  I can tell you 
how to debug the check process, but it's a little tricky.

Duncan Murdoch
#
Dear Duncan,

I don't get it when using R CMD check.

I only get it when building/loading using roxygen2 or when I call 
load_all (which roxygen2 does too, I think). load_all calls load_dll 
which then throws this error. I have registered my routines in 
R_init_secsse.c:

void R_init_secsse(DllInfo *dll)
{
 ? R_registerRoutines(dll, NULL, NULL, FortranEntries, NULL);
 ? R_useDynamicSymbols(dll, FALSE);
}

Any suggestions?

Cheers, Rampal
On 06-Nov-18 22:50, Duncan Murdoch wrote:
#
On 06/11/2018 5:17 PM, Rampal Etienne wrote:
Nope!  Sounds like a bug in devtools/roxygen2, but I don't know either 
of those packages well.

Duncan Murdoch
#
Without code we are guessing.  A bug is possible but I will make another guess suggestion.

Delete all binary files created by devtools during compilation in your package directory.
devtools::load_all() is so fast partly because it recompiles the C/Fortran files only when necessary
but sometimes compilation may be needed even if devtools thinks otherwise.

 Georgi Boshnakov


-----Original Message-----
From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com] 
Sent: 07 November 2018 00:26
To: Rampal Etienne; Georgi Boshnakov; r-package-devel at r-project.org
Subject: Re: [R-pkg-devel] nativeRoutines error when using roxygen2 in RStudio
On 06/11/2018 5:17 PM, Rampal Etienne wrote:
Nope!  Sounds like a bug in devtools/roxygen2, but I don't know either 
of those packages well.

Duncan Murdoch
#
Dear Georgi,

Thanks for the suggestion, but that does not work either.

I can send the code if that would help. But note that the code was
working fine until I installed a new R-devel version. But perhaps there
is an update in how the routines should be registered. I am doing it
like this:

#include <R.h>
#include <Rinternals.h>
#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>

/* .Fortran calls */
extern void F77_NAME(fill1d)(double *vec, int *DIMP, double *parms, int
*II);
extern void F77_NAME(initmod)(void (*steadyparms)(int *, double *));
extern void F77_NAME(runmod)(int *neq, double *t, double *Conc, double
*dConc, double *yout, int *ip);

static const R_FortranMethodDef FortranEntries[] = {
  {"fill1d", (DL_FUNC) &F77_NAME(fill1d),  4},
  {"initmod", (DL_FUNC) &F77_NAME(initmod),  1},
  {"runmod", (DL_FUNC) &F77_NAME(runmod),  6},
  {NULL, NULL, 0}
};

void R_init_secsse(DllInfo *dll)
{
  R_registerRoutines(dll, NULL, NULL, FortranEntries, NULL);
  R_useDynamicSymbols(dll, FALSE);
}

Does that look OK?

Cheers, Rampal
On 7-11-2018 12:45, Georgi Boshnakov wrote:
#
After installing a new version of R the OP may have to rebuild (and retest)
packages like pkgload that define functions by grabbing functions from the
base package and modifying them, as in pkgload/R/namespace-env.r:

onload_assign("makeNamespace",
  eval(
    modify_lang(
      extract_lang(body(loadNamespace),

        # Find makeNamespace definition
        comp_lang, y = quote(makeNamespace <- NULL), idx = 1:2)[[3]],

      # Replace call to .Internal(registerNamespace()) is replaced by a
call to
      # register_namespace
      function(x) {
        if (comp_lang(x, quote(.Internal(registerNamespace(name, env))))) {
          quote(register_namespace(name, env))
        } else {
          x
        }
      }))
)




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Nov 7, 2018 at 3:45 AM, Georgi Boshnakov <
georgi.boshnakov at manchester.ac.uk> wrote:

            

  
  
#
The problem was resolved by installing again a new version of devtools.

However, this new version gives other problems: devtools::check() says
the DESCRIPTION file is missing a License field, but there IS a license
field in this file.
On 7-11-2018 16:59, William Dunlap wrote:

  
  
#
Also note that William's suggestion is documented at the bottom of the
"Generic Functions and Methods" section of Writing R Extensions.
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Generic-functions-and-methods

"... as a package can take over a function in the base package and
make it generic by something like
    foo <- function(object, ...) UseMethod("foo")
    foo.default <- function(object, ...) base::foo(object)
"Earlier versions of this manual suggested assigning foo.default <-
base::foo. This is not a good idea, as it captures the base function
at the time of installation and it might be changed as R is patched or
updated."

Best,
Josh

On Wed, Nov 7, 2018 at 10:45 AM Rampal S. Etienne
<rampaletienne at gmail.com> wrote: