-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
roxygenize error: "Caused by error in basename()
: a character vector argument expected"
#1589
Comments
Same issue here and I can't tell from the error which S3 method is missing a tag. |
I got the same issue, but no methods were missing tags. Restarting the R session made it go away... |
I restarted several times and it did not work. And then, did some work, restarted and it magically stopped throwing errors. |
The same issue is on GitHub Actions. How to solve it? Use the previous version of Roxygen2 where the issue was not present? |
Yes, you can work around it by reverting to roxygen2 version 7.2.3. Or, you can give up and add |
I just figured out when this happens for me. If I have a breakpoint setup inside a method, and I run document(), the above error would appear. Removing the breakpoint removes the error. There may be multiple causes of the same error, but this is what was causing it for me. Reproducible example: #' @export
summary.myclass <- function(object) {
cat("This is a summary of myclass\n")
} running and I run Error in `map2()`:
ℹ In index: 1.
ℹ With name: summary.myclass.
Caused by error in `basename()`:
! a character vector argument expected
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
In class(f) <- c("s3method", "function") :
Setting class(x) to multiple strings ("s3method", "function", ...); result will no longer be an S4 object |
I experienced the same problem when building my package with roxygen2 version 7.3.0 and 7.3.1 (everything works fine with version 7.2.3) in Rstudio (v2024.04.1 Build 748). In my case, roxygen2 stops when analyzing a file containing the definition of an S4 class. Strangely, it seems to be related to the name of the class (i.e. fitted.graph). Here is a minimal example that (hopefully) reproduces the error in other systems:
If I add @export (or @exportClass), the error persists. But if I simply change the name of the class (which I am reluctant to do in my whole package) to e.g. f.graph then the error disappears.
Additional trial and error testing suggests that the problem is related to the prefix fitted in the name of my class. |
This seems related to this section of the release notes for 7.3.0 of roxygen2:
|
Agree, it's related to that. The problem is that in trying to print the error message, roxygenize is itself throwing an error. |
The problem persists even when using "@exportS3Method NULL" (even in the toy example). The way I solved it was to give the generator function created by the SetClass function a name different from the name of the class: i.e. following the above toy example:
Note that this works even without @export tag. |
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:
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 withdebug
helps to show what the trouble is:So
warn_roxy_function
is trying to create a warning message based onattr(fun, "srcref")
, but the attribute value is empty, which causes an error further down the line.The text was updated successfully, but these errors were encountered: