Bug 16120 - Updating and attaching a loaded package leads to inconsistent visibility
Summary: Updating and attaching a loaded package leads to inconsistent visibility
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.1.2
Hardware: Other Other
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-12-26 12:59 UTC by Duncan Murdoch
Modified: 2014-12-26 23:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Murdoch 2014-12-26 12:59:22 UTC
If you load the namespace of a package, then update the package and attach it, you will see the help files from the new version but the functions from the old version.

For example, currently on CRAN the rgl package has OS X binary version 0.93.1098 but source version 0.95.1201.  So doing the following will load the old version:

install.packages("rgl")
loadNamespace("rgl")

After this, the version is listed by sessionInfo as loaded but not attached:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] rgl_0.93.1098 tools_3.1.2  


Now, in the same session, install and attach the source version to get the new one:

install.packages("rgl", type="source")
library("rgl")

At this point sessionInfo() lists the attached new version, not the old one:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgl_0.95.1201

loaded via a namespace (and not attached):
[1] tools_3.1.2

However, we see functions from the old one.  For example, readOBJ() is new.  We
can see the help page using ?readOBJ, but not the function itself:

> readOBJ
Error: object 'readOBJ' not found

A workaround is to call unloadNamespace("rgl") and then attach it again, but shouldn't library() either do this, or declare an error if it is not possible?
Comment 1 Duncan Murdoch 2014-12-26 23:40:31 UTC
Fixed in R-devel; soon in R-patched.