Skip to content

Error when running roxygenise #28

@dupontct

Description

@dupontct

Running roxygenise with a unmodified code lead to the following.

>library(roxygen3)
> roxygenise('.')
Loading PResiduals
Loading required namespace: Formula
@method is deprecated. S3 methods are now detected automatically.
Error in get(as.character(FUN), mode = "function", envir = envir) :
  object 'process_family' of mode 'function' was not found

> traceback()
8: get(as.character(FUN), mode = "function", envir = envir)
7: match.fun(process) at bundle.r#24
6: f(...) at memoise.r#28
5: cached_processor(process, input) at bundle.r#7
4: .local(input, ...)
3: process(pkg) at all-generics.r#37
2: process(pkg) at roxygenise.r#31
1: roxygenise(".")

This appears to be an namespace issue with memoise. It can be duplicated using the following code placed in a namespac where foobar, foo, and bar are exported and bob is not exported.

bob <- function(input) {
  input + 5
}

foo <- function(process, input) {
  a <- match.fun(process)

  a(input)
}

bar <- memoise(foo)


foobar <- function() {
  cat('Running foo\n')
  print(foo('bob', 5))
  cat('Running bar\n')
  print(bar('bob', 5))

  return("done")
}

Then running the following code

foobar()

You get the following output

> foobar()
Running foo
[1] 10
Running bar
Error in get(as.character(FUN), mode = "function", envir = envir) :
  object 'bob' of mode 'function' was not found
Calls: foobar -> print -> bar -> f -> match.fun -> get

> traceback()
6: get(as.character(FUN), mode = "function", envir = envir)
5: match.fun(process) at TempTest.R#6
4: f(...) at memoise.r#28
3: bar("bob", 5)
2: print(bar("bob", 5)) at TempTest.R#18
1: foobar()

so foo() runs correctly however the memoise version of foo() bar() does not. As near as I can tell its because match.fun() is looking for 'bob' in the memoise namespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions