[Rd] improve 'package not installed' load errors?
Kevin Ushey
kevinushey at gmail.com
Mon Oct 24 19:51:05 CEST 2016
Hi R-devel,
One of the more common issues that new R users see, and become stumped
by, is error messages during package load of the form:
> library(ggplot2)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()),
versionCheck = vI[[j]]) :
there is no package called 'Rcpp'
Error: package or namespace load failed for 'ggplot2'
Typically, error messages of this form are caused simply by one or
more dependent packages (in this case, 'Rcpp') not being installed or
available on the current library paths. (A side question, which I do
not know the answer to, is how users get themselves into this state.)
I believe it would be helpful for new users if the error message
reported here was a bit more direct, e.g.
> library(ggplot2)
Error: 'ggplot2' depends on package 'Rcpp', but 'Rcpp' is not installed
consider installing 'Rcpp' with install.packages("Rcpp")
In other words, it might be helpful to avoid printing the
'loadNamespace()' call on error (since it's mostly just scary /
uninformative), and check up-front that the package is installed
before attempting to call 'loadNamespace()'. I'm sure a number of
novice users will still just throw their hands up in the air and say
"I don't know what to do", but I think this would help steer a number
of users in the right direction.
(The prescription to suggest installing a package from CRAN if
available might be a step too far, but I think making it more clear
that the error is due to a missing dependent package would help.)
Any thoughts?
Kevin
More information about the R-devel
mailing list