在R Shiny应用程序中自动删除的临时文件-文件错误:无法打开连接 [英] Temp files automatically deleted in R shiny app - Error in file: cannot open the connection
问题描述
我创建了一个R Shiny应用程序,该程序每天使用批处理文件自动运行。
启动应用程序时,一切正常,但第二天崩溃,我收到以下消息:
I created a R shiny app that automatically runs every day using a batch file. Everything works fine when lauching the app, but the next day it crashes and I get the following message:
Warning in file(open = "w+") :
cannot open file
'C:\Users\bertin\AppData\Local\Temp\RtmpKiBPOU\Rf3f835d1a66' : No such file or directory
Warning: Error in file: cannot open the connection
[No stack trace available]
实际上,此问题与执行闪亮应用程序的R会话创建的 tempdir()
文件夹有关。一定时间后,此文件夹将自动删除。每次刷新时都必须删除所有Temp文件吗?还是相反,需要防止R删除Temp文件夹上的所有闪亮的临时文件?谢谢!
Actually this issue is related to the tempdir()
folder created by the R session executing the shiny app. This folder is automatically deleted after a certain time. Do I have to delete all Temp files on each refreshing? Or on the contrary is it needed to prevent R from deleting all shiny temp files on Temp folder? Thanks!
编辑-这是有意产生错误的方法:
Edit - Here is how to intentionally generate the error:
tempdir()
dir.exists(tempdir())
library(shiny)
# Windows shell required
shinyApp(
ui = fluidPage("Please reload to see me fail."),
server = function(input, output) {
shell(paste("rmdir", dQuote(
normalizePath(tempdir(), winslash = "/", mustWork = FALSE), q = FALSE
), "/s /q"))
}
)
推荐答案
现在,我已经在Windows 10(Storage Sense)中找到了有关删除临时文件的设置,该设置似乎已被激活
By now I've found a setting in Windows 10 (Storage Sense) concerning the deletion of temporary files, which seems to be active by default.
导航如下,并取消选中:
- 设置
- 系统存储
- 存储意识
- 更改我们自动释放空间的方式
- 删除临时文件我的应用未使用
- Settings
- System Storage
- Storage Sense
- Change how we free up space automatically
- Delete temporary files that my apps aren't using
这篇关于在R Shiny应用程序中自动删除的临时文件-文件错误:无法打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!