[Rd] disappearing tempdir()

William Dunlap wdunlap at tibco.com
Tue Apr 24 22:52:34 CEST 2018


Recent versions of Windows will remove empty directories from areas that
Windows considers places for temporary files.  It does not seem to matter
how old they are; empty directories are found and removred  c. once a day.
I haven't seen any documentation on this feature but I think you can turn
if off by disabling "Storage Sense" in Settings>System>Storage.

This means that R's tempdir() can easily disappear unless you put a file in
it.  I think an empty file will do the trick.  Perhaps R could do this when
it makes a new tempdir().  (When the file gets old, 30 days?, it will be
removed and then the empty directory holding it will be removed, but that
is better than the current situation.)

On a related note, R-3.5 has a new argument to tempdir: check=FALSE.  If
'check' is TRUE then tempdir() will make a new directory, with a new name,
in which to hold temporary files.  If it first tried to make a new
directory with the name of the previous tempdir() then things like fix(),
which cache the name of a file in tempdir(), will continue to work.  Is the
plan to make check=TRUE the default in tempdir(), or perhaps have
tempfile() call tempdir(check=TRUE)?  Then we would not have problems like

> file.rename(tempdir(), paste0(tempdir(), "~")) # mimic Windows cleaner
[1] TRUE
> file.create(tempfile())
[1] FALSE
Warning message:
In file.create(tempfile()) :
  cannot create file '/tmp/RtmpHKpWnV/file67f416dcb511', reason 'No such
file or directory'


Bill Dunlap
TIBCO Software
wdunlap tibco.com

	[[alternative HTML version deleted]]



More information about the R-devel mailing list