9

I am developing an R package (let's call it pkg), and I have defined a few generics. The NAMESPACE file contains both

S3method(foo, bar)
export(foo)

However, upon calling pkg::foo.bar, I get the dreaded

Error: 'foo.bar' is not an exported object from 'namespace:pkg'

I am using roxygen2, if that changes anything.

Note: If I explicitly add export(foo.bar), then everything works.

JohnA
  • 321
  • 2
  • 11
  • if you use `devtools`, `@export` for all generic/methods? it always [worked fine](https://github.com/vbonhomme/Momocs/blob/master/R/core-out-efourier.R) for me (more doc [here](http://r-pkgs.had.co.nz/namespace.html#exports). Is `foo` a method you created or do you extend one ? – Vincent Bonhomme Apr 06 '16 at 05:36
  • Yes, all generics are exported.`foo` is a method that I created, and is being called from another package I am writing (e.g. `secondPkg` imports `pkg` and is trying to call `pkg::foo.bar`). – JohnA Apr 06 '16 at 14:37
  • 13
    I had same problem...many expletives later I discovered that NAMESPACE (and thus exports) is **only** updated when you run devtools::document() - not devtools::build() or devtools::install() – virgesmith Feb 22 '17 at 15:42
  • 3
    @virgesmith: This solved my problem too. Please consider writing an answer. – miguelmorin Mar 11 '19 at 16:28

1 Answers1

2

NAMESPACE (and thus exports) is only updated when you run devtools::document() - not devtools::build() or devtools::install().

its.me.adam
  • 333
  • 2
  • 11