Open HenrikBengtsson opened 4 years ago
With #83 implemented, the above will look like:
local({
if (utils::file_test("-f", ".RData")) {
fn_hide <- tempfile(".RData.", tmpdir = ".")
if (file.rename(".RData", fn_hide)) {
message("Hiding .RData")
startup::on_post_startup({
message("Unhiding .RData")
file.rename(fn_hide, ".RData")
})
}
}
})
The problem with R_STARTUP_RDATA=skip
is that it cannot be reliably be implemented as an atomic transaction, e.g. if two R processes launch at the same, one process may "hide" the .RData file so that the first one does not see it, and then "unhide" so that the second R process will actually load it.
It's possible to "hide" and then "unhide" a
.RData
during the R startup process by renaming it and then creating a.First()
function to un-rename it. This would make it possible to also supportR_STARTUP_RDATA=skip
with a warning and askip-silently
to skip without a message.Working prototype:
Care needs to be taken such that any existing
.First()
is not overridden.