When I try to run my .Rmd document I get an error :
Output created: /tmp/RtmpIJCtdZ/file443d7655998c.html
Warning: Error in value[[3L]]: Couldn't normalize path in addResourcePath, with arguments: prefix = 'mathjax-local'; directoryPath = '/usr/lib/rstudio-server/resources/mathjax-26'
122: stop
121: value[[3L]]
120: tryCatchOne
119: tryCatchList
118: tryCatch
117: shiny::addResourcePath
116: shinyHTML_with_deps
115:
99: doc
98: shiny::renderUI
97: func
84: origRenderFunc
83: output$reactivedoc
3:
1: rmarkdown::run
I have tried to update all packages and run , still it did not work.
Using the environment it was created in using renv() was the solution. Looks like the issue was with updated packages.
Related
I'm working on a rather complex app but will provide the most succinct snippets of code to exemplify the issue I'm having. In short I have a function which returns the path to a generated .gif file. I would like to render that newly created image with renderImage.
#Here is the eventReactive that fires a long running process which produces the gif file
animation <- eventReactive(input$animate, {
file <- file()
param <- input$param
lyr <- input$lyr
step <- time_in_secs()
a %<-% animation_handler(file, param, lyr, lisgrid, step)
f <- futureOf(a, default="./src/placeholder-image.png")
if(resolved(f)) {
print("Future resolved!")
return(a)
}
})
renderText({animation()})
renderImage({animation()})
What is so puzzling to me is that the renderText part works just fine and shows me the path to the created .gif. The renderImage line however gives me this error:
Warning: Error in : $ operator is invalid for atomic vectors
101: %||%
100: transform
99: func
97: f
96: Reduce
87: do
86: hybrid_chain
85: renderFunc
84: output$outaac7603e20b14e63
3: <Anonymous>
1: rmarkdown::run
Removing the renderImage line I do not get any errors, although I also obviously don't get the image I'm looking for.
The issue is weird in the sense that I can recreate the exact same PDF report with knitr outside of the Shiny app. The code does work if I use HTML as output format. I have the latest version from MikTex
See code below:
output$report <- downloadHandler(
filename = paste(Sys.Date(), "GebiedsRapportage.html"),
content = function(file) {
#tempReport <- file.path(tempdir(), "report_html.Rmd")
tempReport <- file.path(tempdir(), "report_pdf.Rmd")
#file.copy("report_html.Rmd", tempReport, overwrite = TRUE)
file.copy("report_pdf.Rmd", tempReport, overwrite = TRUE)
rmarkdown::render(tempReport, output_file = file)
}
)
So, using the #HTML functions works fine, but the PDF function gives me the following error:
Warning: running command '"pdflatex" -halt-on-error -interaction=batchmode "file2e8466131256.tex"' had status 1
Warning: Error in : Failed to compile file2e8466131256.tex.
Stack trace (innermost first):
58: show_latex_error
57: on_error
56: system2_quiet
55: run_engine
54: latexmk_emu
53: tinytex::latexmk
52: latexmk
51: rmarkdown::render
50: download$func [server/server_data_analysis.R#311]
1: runApp
Error : Failed to compile file2e8466131256.tex.
While knitting the file itself without interacting with Shiny generates a PDF perfectly fine.
Anyone encountered the same issue?
I have just installed shiny 1.0.5 in Ubuntu 14.04.5 LTS and am receiving a segmentation fault on the default landing page. The last bit of the Javascript console/hello error log is:
89: .Call("httpuv_run", PACKAGE = "httpuv", timeoutMillis)
90: run(timeoutMs)
91: service(timeout)
92: serviceApp()
93: withCallingHandlers(expr, error = function(e) { if (is.null(attr(e, "stack.trace", exact = TRUE))) { calls <- sys.calls() attr(e, "stack.trace") <- calls stop(e) }})
94: captureStackTraces({ scheduleFlush() while (!.globals$stopped) { serviceApp() Sys.sleep(0.001) }})
95: ..stacktraceoff..(captureStackTraces({ scheduleFlush() while (!.globals$stopped) { serviceApp() Sys.sleep(0.001) }}))
96: runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE)
An irrecoverable exception occurred. R is aborting now ...
-su: line 1: 2739 Segmentation fault (core dumped) R --no-save --slave -f \/opt\/shiny-server\/R\/SockJSAdapter\.R
Also, from the beginning of the log file:
*** caught segfault ***
address 0xbd, cause 'memory not mapped'
Any tips on debugging this and getting it running?
I don't ultimately know what the issue is, but upgrading to R 3.4.2 had completely broken Shiny. Removing r-base (r-base-core, etc) via apt and reinstalling 3.3.3 fixed the issue, though it remains frustrating.
I have a Shiny application that I run by calling a function that calls shiny::runApp. The application can access the global environment, therefore it can access to data in objects that have a name decided in advance. However, I would like to pass it data through the parameters of the function that runs the app. The following example works.
f <- function(param) {
runApp(
list(
ui = fixedPage({
verbatimTextOutput('text')
}),
server = function(input, output) {
output$text <- renderPrint(param)
})
)
}
f("hello")
However, I can not reproduce this behaviour when the ui and server components are loaded from a file:
File contents:
$ cat ui.R
fixedPage({
verbatimTextOutput('text')
})
$ cat server.R
function(input, output) {
output$text <- renderPrint(param)
}
R code:
g <- function(param) {
runApp()
}
g("hello")
Error message:
Listening on http://127.0.0.1:3870
Warning: Error in renderPrint: object 'param' not found
Stack trace (innermost first):
86: renderPrint
85: func
84: eval
83: eval
82: withVisible
81: evalVis
80: utils::capture.output
79: paste
78: origRenderFunc
77: output$text
2: runApp
1: g [#2]
I guess that it has something to do with the fact that the components are not created in similar scopes in the two examples, but I could not find a workaround... In the second example, is there a way where I can access the environment of the function g from the Shiny app ?
Yes. Define the param object in the global environment:
g <- function(param) {
assign("param",param,.GlobalEnv)
runApp()
}
#this now works and print `hello` as intended
g("hello")
I have never seen this error before running a Shiny app and can't find anything about it after Googling. I've tried re-installing the shiny package and restarting R but nothing resolves it. Any insight?
Error after running runApp() from the local directory:
Listening on http://127.0.0.1:6093
Warning: Error in ..stacktraceon..: could not find function "shioptions"
Stack trace (innermost first):
1: runApp
Error in ..stacktraceon..({ : could not find function "shioptions"
Traceback below:
5: Sys.sleep(0.001)
4: withCallingHandlers(expr, error = function(e) {
if (is.null(attr(e, "stack.trace", exact = TRUE))) {
calls <- sys.calls()
attr(e, "stack.trace") <- calls
stop(e)
}
})
3: captureStackTraces(while (!.globals$stopped) {
serviceApp()
Sys.sleep(0.001)
})
2: ..stacktraceoff..(captureStackTraces(while (!.globals$stopped) {
serviceApp()
Sys.sleep(0.001)
}))
1: runApp()
Check the library("shiny") output from your R Console. I think you do not have the package loaded and/or you had an intentional upgrade.