Output of sessioninfo::session_info()():
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plumber_1.0.0 jsonlite_1.7.2 base64enc_0.1-3 venn_1.9
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 compiler_4.0.3 later_1.1.0.1 routr_0.4.0 dashHtmlComponents_1.0.3
[6] dashCoreComponents_1.10.0 tools_4.0.3 digest_0.6.27 uuid_0.1-4 lifecycle_0.2.0
[11] rlang_0.4.10 dash_0.5.0 fiery_1.1.3 parallel_4.0.3 xfun_0.20
[16] swagger_3.33.1 xml2_1.3.2 admisc_0.11 globals_0.14.0 reqres_0.2.3
[21] triebeard_0.3.0 glue_1.4.2 listenv_0.8.0 R6_2.5.0 brotli_1.2
[26] parallelly_1.23.0 magrittr_2.0.1 urltools_1.7.3 codetools_0.2-16 promises_1.1.1
[31] htmltools_0.5.1.1 webutils_1.1 assertthat_0.2.1 future_1.21.0 httpuv_1.5.5
[36] tinytex_0.29 stringi_1.5.3 crayon_1.4.0
library(venn)
library(plumber)
#* @get /getAVenn
getAVenn <- function() {
venn("A*~B", snames = "A, B",sncs = 4)
getAVenn()
This issue is only present when calling the function through the api generated by plumber. Calling the above function within the R script works just fine. When called through the api, the following error is given
<simpleError in parse(text = paste(unlist(lapply(sys.calls(), deparse)), collapse = "\n")): <text>:30:4: unexpected '<'
29: invisible()
30: })(<
^>
Unfortunately, that's the whole error. I'm not sure where that line of code even exists. It's not in my files, and I searched the Plumber repo as well for the string "paste(unlist" and it returned no results. Maybe a dependency? This error occurs on MacOS Big Sur, Windows 10, and Ubuntu 20.04
library(venn)
library(plumber)
#* @get /getAVenn
#* @serializer png
function() {
venn("A*~B", snames = "A, B",sncs = 4)
}
There is definitly something not working there.
@meztez
plumb(file='ISPeL/question_generation/Set-Operations-api/justVennandPlumber.R')$run()
Error in throw_if_func_is_not_a_function(private$func) :
exprdid not evaluate to a function
It comes from a parse inside the venn call stack, it is parsing a text that contains a single non-printable character. No clue so far how to resolve that.
Reprex not involving plumber:
# saves file
local({
png("test_plot_fg.png")
on.exit({dev.off()})
plot(1:10, 1:10)
})
# saves file
callr::r(function() {
png("test_plot_bg.png")
on.exit({dev.off()})
plot(1:10, 1:10)
})
#> NULL
# produces error
local({
png("test_fg.png")
on.exit({dev.off()})
venn::venn("A*~B", snames = "A, B", sncs = 4)
})
#> Error in parse(text = paste(unlist(lapply(sys.calls(), deparse)), collapse = "\n")): <text>:149:25: unexpected '<'
#> 148: }, list(input = structure("/private/var/folders/0k/bxg5lhr92sq74mb1d446ql540000gp/T/RtmpJuEAi9/reprex141b01288b6b3/reprex_reprex.R", class = c("fs_path",
#> 149: "character"))), envir = <
#> ^
# produces error
callr::r(function() {
png("test_bg.png")
venn::venn("A*~B", snames = "A, B", sncs = 4)
on.exit({dev.off()})
})
#> Error: callr subprocess failed: <text>:150:20: unexpected '<'
#> 149: })
#> 150: }, list(), envir = <
#> ^
Created on 2021-03-05 by the reprex package (v0.3.0)
The venn plot does save to an image when done with an interactive R session.
This is a bug in admisc: https://github.com/cran/admisc/search?q=lapply%28sys.calls%28%29%2C+deparse which venn imports directly. Unfortunately, I do not see a URL to post a bug.
Thank you for the information, and for the Reprex example. I'll look into that tool for future use. I'll close this issue and pursue an answer with the developer of th admisc package.
This is a bug in
admisc: https://github.com/cran/admisc/search?q=lapply%28sys.calls%28%29%2C+deparse whichvennimports directly. Unfortunately, I do not see a URL to post a bug.
The link to post / report bugs in package admisc is:
https://github.com/dusadrian/admisc/issues
This is unrelated to package admisc, however. I've added a dummy function foo() on the GitHub repo, containing just this line:
foo <- function(x) {
return(parse(text = paste(unlist(lapply(sys.calls(), deparse)), collapse = "\n")))
}
This seems to be causing the issue, but all of these are just base functions and they do work from an interactive R prompt. Using R version 4.0.3, this reprex works:
remotes::install_github("dusadrian/admisc", ref = "efcdb0c86c276cae2f8846ced2c3c68656f2500a")
local(admisc::foo(3))
# expression(local(admisc::foo(3)), eval.parent(substitute(eval(quote(expr), envir))),
# eval(expr, p), eval(expr, p), eval(quote(admisc::foo(3)), new.env()),
# eval(quote(admisc::foo(3)), new.env()), admisc::foo(3))
while this doesn't work:
callr::r(function() { admisc::foo(3) })
# Error: callr subprocess failed: <text>:146:20: unexpected '<'
# 145: admisc::foo(3)
# 146: }, list(), envir = <
# ^
# Type .Last.error.trace to see where the error occured
It seems to be related to package callr, and if package plumber uses that package, that is most likely the relevant place to file a bug report.