[Rd] Reproducible use case for R crash after updating R

Henrik Bengtsson hb at biostat.ucsf.edu
Thu May 12 19:55:34 CEST 2011


This might have been discussed before, but below is a
"not-so-unlikely" use case where the user follows normal procedures,
updates R to a major release version, and then R crashes:

1. Use runs R stable (e.g. v2.13.0).
2. User installs a package with a namespace, e.g. install.packages("fortunes").
3. User uses the package and one of the package's objects are assigned
to the global env, e.g. foo <- fortune.
4. The user quits R and stores the session data, e.g. q("yes").  The
session is stored in users home directory.
5. User update to new major release of R (e.g. 2.14.0).
6. User starts R.  R crashes with "Fatal error: unable to restore
saved object in .RData" because 'fortunes' is not installed for this
new version of R.  There is also an error message before that
reporting "Error in loadNamespace(name) : there is no package called
'fortunes'".

This can also be reproduced using a single R version as follows:

1. Start R and do:
install.packages("fortunes")
library("fortunes")
foo <- fortune
remove.packages("fortunes")
q("yes")
2. Restart R.  R crashes.

For a GUI-only user this is complicated, because although the users
sees the informative error message that "Error in loadNamespace(name)
: there is no package called 'fortunes'", s/he cannot get to the point
where it is possible to install that missing package.  The key for the
user is to understand to remove the .RData.  In order to do this, s/he
has to locate that file first.

To simplify this, a few alternatives exists:

1. R reports the full path to the problematic .RData file.
2. R renames the problematic .RData file to
erroneous_20110512-123404UTC.RData and reports the new full pathname.

In both cases there could be the option for R to either exit, or
ignore the problematic .RData file and give the user access to the
prompt.  One could also imaging a fancy recovery feature where R
detects "erroneous" .RData files and asks the user if s/he wish to try
to load them (maybe the packages has been installed since).

I'm sure there are complications to implement the above, because
.RData is loaded during startup, but that's my $.02 to this problem

/Henrik



More information about the R-devel mailing list