2

I'm running a shiny app locally on my Windows machine that auto-runs every day using a batch file. I recently ran into an issue lately where the R tmp directory /tmp/RtmpXXXXX is removed and the application fails:

Warning in file(open = "w+b", encoding = "UTF-8") :
  cannot open file 
'C:\Users\Carlos\AppData\Local\Temp\Rtmp0maCtT\Rf140c40ab30be': No such file 
or directory  # deleted file
Warning in normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="C:\Users\Carlos\AppData\Local\Temp\Rtmp0maCtT": The system cannot 
find the file specified  # deleted folder
Warning in file(open = "w+") :
  cannot open file 
'C:\Users\Carlos\AppData\Local\Temp\Rtmp0maCtT\Rf140c38044f8': No such file 
or directory
Warning: Error in file: cannot open the connection  # program crashes
Stack trace (innermost first):
    1: runApp
Error : cannot open the connection

How should I manage a temporary directory that automatically gets deleted after a certain amount of time? I tried changing the file path to see if that would resolve the issue, but that didn't work.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

1

I ran procmon and noticed that Windows Disk Cleanup was removing temporary files automatically almost every day, affecting the session's temporary directory and causing the shiny app to crash.

procmon_logfile

To disable this automatically scheduled task :

  • Open Task Scheduler
  • Drill down to Task Scheduler Library > Microsoft > Windows
  • Click on DiskCleanup
  • In the right-hand pane click Disable