On Mon, 18 May 2009, Dirk Eddelbuettel wrote:
>
> I was trying to be cute with a company-internal package and used
>
> if (Sys.info()["sysname"]=="Windows") {
> update.packages(repos="http://some.where.internal/R",
ask=FALSE)
> }
The commonly used test is .Platform$OS.type == "windows": that value
is computed at installation so will be marginally faster.
> but that of course fails as the package itself is loaded and cannot be
> upgraded (as it contains a dll) when loaded. Smart move by the OS.
It's not only Windows that has that problem, but it does at least
report it. Some Unixen used (at least) to let you replace a DSO which
is in use, and then crash the process using the DSO.
That's an issue with automated updating of R packages in a centrally
managed system, so we do it during 'at risk' periods when activity is
expected to be low.
> Can anybody suggest a workaround, other than introducing a dll-free wrapper
> package that can in fact test for the local packages before it would load
> them?
Can you not run a check of up-to-date-ness in the .onLoad hook for the
package? If you load the DLL in that hook, this can be run before the
DLL is loaded. This would need either each package only to update
itself or the check to be in all packages that might get updated.
You could unload the loaded namespace, provided it has a .onUnload()
action that calls library.dynam.unload(), re-install then re-load.
However, we've seen instances where unloading and re-loading a DLL in
a session did not work (crashes etc) for various reasons -- it does
not for example re-load and hence re-initialize any dependendent DLLs.
> Placing the test into Rprofile.site is not a valid answer as that file is
> hiding on each user's drive and out of my reach.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595