Skip to content
Prev 44830 / 63424 Next

Patch for setwd() to show path in error message

On Fri, Jan 11, 2013 at 10:40 PM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
Risking to state the obvious:

To me, the main purpose of error messages is to make troubleshooting
easier. The more informative the error message is, the easier it is to
troubleshoot and the faster the origin of the error can be resolved.
The other extreme is to provide an empty error message (stop("")) and
leave it to whoever needs to troubleshoot to use traceback() and
debug() and/or inspect the source code.

Also, a well written error message makes it more likely that the end
user will be able to resolve the problem without asking others for
help (read r-help, the maintainer, an R savvy person that the user
happens to know, ...).  As an example of this, over at
aroma-project.org I receive fewer support emails after updating the
format of file-not-found error messages from:

  Pathname not found: R-devel/src/library/base/R/R/utils.R

to:

  Pathname not found: R-devel/src/library/base/R/R/utils.R
(R-devel/src/library/base/R/ exists, but nothing beyond; current
directory is 'x:/CRAN')


Moreover, it is not always the person who receives/reads the error
message that is the one who will resolve the problem.  In some cases
it is not even possible for that person to access the environment
where the problem occurs.  However, as a good R citizen, the more
troubleshooting you can at your end before requesting help by the
person who can take action the better.  This also makes it more likely
that the error will be resolved sooner.

As my postscript hinted to, this post originates from an error in the
'R CMD check' service ran by r-forge.r-project.org).  That particular
error is likely to occur internally in tools:::.check_packages();

 if (nzchar(libdir)) {
   setwd(libdir)
   ...
 }

where 'libdir' is an internal object, but there is no way for me (and
all the others who also see this error for their packages) to help out
with the troubleshooting.

/Henrik