Skip to content

roxygenize error: "Caused by error in basename(): a character vector argument expected" #1589

Open
@andrew-schulman

Description

@andrew-schulman

I've been successfully building my package documentation until now, up through roxygen2 7.2.3. But with version 7.3.0 and later, it fails:

> roxygen2::roxygenize(roclets = c('rd','collate','namespace','vignette'))
ℹ Loading DMRI
Error in `map2()`:In index: 1.With name: log.debug.
Caused by error in `basename()`:
! a character vector argument expected
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/purrr_error_indexed>
Error in `map2()`:In index: 1.With name: log.debug.
Caused by error in `basename()`:
! a character vector argument expected
---
Backtrace:1. └─roxygen2::roxygenize(...)
  2.   └─base::lapply(...)
  3.     ├─roxygen2 (local) FUN(X[[i]], ...)
  4.     └─roxygen2:::roclet_process.roclet_namespace(X[[i]], ...)
  5.       └─roxygen2:::warn_missing_s3_exports(blocks, env)
  6.         └─purrr::map2(...)
  7.           └─purrr:::map2_("list", .x, .y, .f, ..., .progress = .progress)
  8.             ├─purrr:::with_indexed_errors(...)
  9.             │ └─base::withCallingHandlers(...)
 10.             ├─purrr:::call_with_cleanup(...)
 11.             └─roxygen2 (local) .f(.x[[i]], .y[[i]], ...)
 12.               └─roxygen2:::warn_roxy_function(fun, "S3 method {.arg {name}} needs @export or @exportS3method tag")
 13.                 └─roxygen2:::warn_roxy(file, line, message, parent = parent, envir = envir)
 14.                   ├─cli::style_hyperlink(...)
 15.                   │ └─base::paste0(...)
 16.                   ├─base::paste0(basename(file), ":", line)
 17.                   └─base::basename(file)
Run rlang::last_trace(drop = FALSE) to see 4 hidden frames.

Apparently one of my S3 methods is missing an @export tag, but since the warning message fails, I can't tell which one. Running again with debug helps to show what the trouble is:

> debug(roxygen2:::warn_roxy_function) 
> roxygen2::roxygenize(roclets = c('rd','collate','namespace','vignette'))
Setting `RoxygenNote` to "7.3.1"Loading DMRI
debugging in: warn_roxy_function(fun, "S3 method {.arg {name}} needs @export or @exportS3method tag")
debug: {
    srcref <- attr(fun, "srcref")
    file <- attr(srcref, "srcfile")$filename
    line <- as.vector(srcref)[[1]]
    warn_roxy(file, line, message, parent = parent, envir = envir)
}
Browse[2]> attr(fun, "srcref")
NULL

So warn_roxy_function is trying to create a warning message based on attr(fun, "srcref"), but the attribute value is empty, which causes an error further down the line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions