I have had various R Shiny applications running successfully (some for over a year) on a Windows PC serving a local intranet network.
In the last couple of weeks, the applications started to fail loading plots with the error:
unable to start png() device.
Restarting the application would fix the problem, but only for a few hours when it would error again.
At the time I had not changed anything in R, although since the isuue started I have updated everything hoping it would fix the problem. There was no change after the updates.
When I load an app that is freshly restarted there are no warnings. When there are errors, the console prints the following:
unable to open file 'C:\Users\jgerla03\AppData\Local\Temp\Rtmp4QtNQ2\file91819b61552' for writing
Warning in dev_fun(file = tempfile(), width = width %||% 640, height = height %||% :
opening device failed
Warning: Error in dev_fun: unable to start png() device
107: dev_fun
106: gg2list
105: ggplotly.ggplot
102: plotly_build.gg
98: getFromNamespace("prepareWidget", "plotly")
97: shinyRenderWidget
96: func
83: renderFunc
82: output$fmc_summary_plot
1: shiny::runApp
Warning in normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:\Users\jgerla03\AppData\Local\Temp\Rtmp4QtNQ2": The system cannot find the file specified
The shiny apps are run from an admin account with highest privileges (run from Windows 10 Task Scheduler or commandline). The appdata temp folder specified in the error message gives all users permission to read/write/everything, but the toggle saying "read only" is on everytime I open the "properties" window for the folder (despite me unclicking it and applying each time).
I am so confused because everything works perfectly for the first few hours after a restart which makes this issue more difficult to test.
This seems similar to Error: unable to start png() device in R Shiny Dashboard , which never received a response. I hope the extra detail I provided will help someone to suggest a solution.
I have seen similar behaviour using a ubuntu shiny server and it was traced back to running out of system resources (disk space in my case) which ment that temporary files could not be created.
Your error message ...
"unable to open file 'C:\Users\jgerla03\AppData\Local\Temp\Rtmp4QtNQ2\file91819b61552'"
looks similar to what I experienced. I'm not familiar with Windows OS but would suggest you look into the possibility that you are running out of disk or memory space..
Peter
Related
A few days ago, I was having an error running models in R using 'brms', which said that my posterior samples didn't exist. Upon reading further, these links (1, 2, 3, 4) led me to think it was an rstan problem playing with my macOS (Catalina 10.15.6).
I followed their instructions, namely:
-updated packages Rcpp, rstan, arm, and brms
-followed these workaround instructions to alter the 'parallel' settings for stan: https://github.com/rstudio/rstudio/issues/6692
-updated R and RStudio, since this problem was supposedly fixed a few months ago with R 4.0
-updated XCode 11, Quartz 11, GNU Fortran 8.2
-updated latest macOS Catalina bug fixes
-ran sudo rm -rf [path to R] to uninstall R
-tried to do a thorough uninstall of all R and RStudio files, including deleting files in my Library/Frameworks folder, any .plist files in Library/Preferences, and any .Rprofile, .Rscript, .Rapp, .Rhistory, or .Renvirons files
-reinstalled R and RStudio after restart
Now, instead of having a "blank slate" to start from, I am experiencing some super weird behaviors. First, RStudio opens on a completely white blank screen and never loads. Second, when I try to open R directly either via terminal or with R Console, I get stuck in a loop for nearly 20 min that says:
Error in socketConnection("localhost", port = port, server = TRUE, blocking = TRUE, :
file descriptor is too large for select()
Calls: <Anonymous> ... makePSOCKcluster -> newPSOCKnode -> socketConnection
Execution halted
Error in socketConnection("localhost", port = port, server = TRUE, blocking = TRUE, :
cannot open the connection
Calls: <Anonymous> ... makePSOCKcluster -> newPSOCKnode -> socketConnection
In addition: Warning message:
In socketConnection("localhost", port = port, server = TRUE, blocking = TRUE, :
port 11537 cannot be opened
Execution halted
At the very end, when it finally stops looping forever, it says:
/Library/Frameworks/R.framework/Versions/4.0/Resources/bin/R: cannot make pipe for command substitution: Too many open files
ERROR: option '-e' requires a non-empty argument
rm: /var/folders/54/km__8z8x78x8_ct1pw8w8bbh0000gn/T//RtmpVORdTy: Too many open files
I can't access a console or enter anything in R to try to troubleshoot. Moreover, it causes a massive slowdown to my computer and Activity Monitor shows more than 150 'R' processes running, which don't go away after quitting R, only after using 'killall R' in Terminal.
However, someone in IT helped me determine that it's something in my Mac user library or preferences, because we created a brand new user on my machine, installed R and RStudio, and had no problems loading them.
I am just a psychology grad student, so I really don't understand the back end that makes R work and I am totally baffled by these symptoms.
I suspect that these links (5, 6, 7) might help, but I don't know how to execute the solutions because right now I can't enter or run anything in R without triggering that endless loop of 'Execution halted.'
I could really use a hand, thanks!
I'm trying to publish an R Shiny app. It works when run locally, but once published to shinyapps.io produces the following error.
Warning in gzfile(file, "wb") :
cannot open compressed file '/key.rda', probable reason 'Permission denied'
Error in value[[3L]](cond) : cannot open the connection
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
You can also see the actual page with the error here: https://povertylab.shinyapps.io/ACS-Map-Dashboard/
Though I have tried to reproduce this error it doesn't appear when I publish other apps, and my searches haven't turned up anything. Other things I've tried: publishing from other computers, publishing only global.R, server.R, and ui.R files, and copying files to a new project and publishing from there.
You can find all code for the app here: https://github.com/Poverty-Lab/ACS-Map-Dashboard
I would appreciate any input, even if it's just guidance on what gzfile is and what the error message could mean. Thank you!
Where is the key.rda file supposed to be? I've looked through your repo and I don't see it, which is probably causing the "cannot open the connection" error.
As a side note, you should probably ignore the .Renviron file; right now anyone can use see and use your key. Make sure you remove it from the history as well.
Thanks all. Turns out this was a problem with the way we were handing the api key for the acs package. We were using api.key.install to install the api key inside the app, and one of api.key.install's default arguments is file = "key.rda", and that file apparently could not be found. I'm still not sure why this problem only came up when we published the app, but we got around it by supplying the actual api key to the acs.fetch function in server.R.
I am currently moving a (localhost) shiny App from a windows 32-bit to windows 64-bit . Google didn't managed to answer my problem :( so I'm asking the community !
This App worked fine on 32 bits, I had to re-install R, all Packages, Java on the 64-bit machine (each in the 64-bit mode). My app has the following file architecture :
a gloabl.R file where I load libraries
a server.R
List item
a ui.R
another file which format data to be sent d3/nvd3
a JS file to display a linechart.
the error I have is the following :
Warning in file(con, "rb") : file("") only supports open = "w+" and
open = "w+b": using the former Warning: Error in readChar: invalid
'nchars' argument Stack trace (innermost first):
1: runApp Error : invalid 'nchars' argument
When I'm running code without shiny, all works fine, all is precessed and results are good.
Does anyone has ever been facing to this ?
If you need anything just ask I will be more specific. I am not giving you the code, he is a little tricky and is in multiple files... And I think it is specific to my new environement.
Reinstalling solely the shiny-package fixed the problem for me. I am using R-studio, and did the operation through the Packages window (deleted and reinstalled).
I want to launch R help, I type ?dir.create. It is giving me this strange error:
Error in file(out, "wt") : cannot open the connection
In addition: Warning message:
In file(out, "wt") :
cannot open file
'C:\Users\XYZ~1\AppData\Local\Temp\Rtmp86bEoJ\Rtxt32dcef24de2': No
such file or directory
Please help me. What do I do to overcome this problem? Even googling this problem didn't give me much info.
This happens when the temporary directory used by R is deleted. This usually happens when user or the system cleans up the tmp directory while the R session is running. Typically happens if the R session is open for a long time.
Remedy is very simple. You don't actually need to restart R. Just re-create the temporary directory by:
tempdir()
# [1] "C:\Users\XYZ~1\AppData\Local\Temp\Rtmp86bEoJ\Rtxt32dcef24de2"
dir.create(tempdir())
NOTE: this happens to me more and more often in Windows 10... even within like 8 hour session only! Not sure why this happens. See this question: https://superuser.com/questions/1502272/windows-10-cleaning-up-my-temp-dir-too-often
Ok.Thank you all.I was able to resolve this by changing the directory and exiting R and re-logging into swirl.
I'm not sure how to make a reproducible example of this, but I'm curious to hear if anyone else has encountered this problem. I have an R Markdown file hosted via shiny server on an EC2 instance running Ubuntu. Everything was working fine for days and now suddenly I get the following error when I try to view the document in the browser:
pandoc document conversion failed with error 127
I'm not converting to pdf, haven't pushed any changes, and it was working a few hours ago. I'm not finding much of anything online about this error code so I have no idea how to debug this issue. Anyone had this happen before?
I faced a similar issue today (see below from .log file):
Warning in system(command) : system call failed: Cannot allocate memory
Warning: Error in : pandoc document conversion failed with error 127
Stack trace (innermost first):
105: pandoc_convert
104: convert
103: render
102: discover_rmd_resources
101: find_external_resources
100: copy_render_intermediates
99: output_format$intermediates_generator
98: <Anonymous>
97: do.call
96: contextFunc
95: .getReactiveEnvironment()$runWith
94: shiny::maskReactiveContext
93: <reactive>
82: doc
81: shiny::renderUI
80: func
79: origRenderFunc
78: output$__reactivedoc__
3: <Anonymous>
2: do.call
1: rmarkdown::run
I too am running Shiny Server via Ubuntu on an EC2 instance, specifically t2.micro. I solved this issue by following the top-voted answer here: How do you add swap to an EC2 instance?
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1
Add to /etc/fstab:
/var/swap.1 swap swap defaults 0 0
In short, you can create swap (memory) space on your EBS (since t2.micro instances don't have ephemeral storage) and this should alleviate your memory issue (without having to move up to a larger EC2 instance).
I had the same error when working with an aws EC2 instance with Ubuntu 16.04 LTS installed and running a shiny app.
My fix: I had some code outside the ui and server functions of my app.R file. I moved all outside code into the server function and the error no longer occurs.
What confused me was that the app still worked most of the time even though some of the code was outside these two functions!
Another thing you could try: Some sources state that this error occurs due to lack of memory. To aid limited memory situation on aws instances, you should provide swap space the system can use to free up memory. Ubuntu on an aws EC2 instance by default has zero swap space! You can use these instructions, google also shows plenty: http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/
This happens when the RAM allocated to your R session is used up completely.
You may have memory leaks in your code.
The simplest fix is to restart the session.
Hard to know for certain what you are asking without an example, but I got the same error trying to "knit to html" from an EC2 instance of RStudio.
This worked for me:
library("rmarkdown")
render("filename.Rmd", "html_document")
I got a similar error when I tried to produce a pdf_document with RStudio from a RMarkdown file. As far as I know: Error 127 means "file not found". Either the file is not there or the path is incorrect.
In my case I got the additional information, that ghostscript was not found. I had recently installed the new version of MacTex with Homebrew. But
Homebrew does … conflict with ghostscript as installed by MacTex
https://github.com/Homebrew/homebrew-core/issues/11368
My solution was to create the symlink to ghostscript as suggested here:
Ghostscript not writable
sudo chown -R `whoami` /usr/local/share/ghostscript
brew link --overwrite ghostscript
The recommended solution is following:
1. Check where R is installed (Lets say it is C drive)
2. Make some space free in C drive from atleast 10 GB recommended
3. Happy Coding
I´m getting this error when transforming a tibble into a table with knitr::kable()
Error: pandoc document conversion failed with error 127
6.
stop("pandoc document conversion failed with error ", result, call. = FALSE)
5.
rmarkdown::pandoc_convert(input = rmarkdown::pandoc_path_arg(mdfile), to = "html", output = rmarkdown::pandoc_path_arg(htmlfile))
4.
print.knit_asis(knitr::asis_output(x))
3.
print(knitr::asis_output(x))
2.
print.knitr_kable(x)
1.
(function (x, ...) UseMethod("print"))(x)
I´ve tryed to:
a) restart the session to refresh the memory
b) install the last pandocs version
But it still does not work...
Thank you very much.
I know this is an old question, but as vivek mentioned, restarting the server worked for me:
sudo systemctl restart shiny-server