[R] Preventing loading of user packages
Brian Diggs
brian.s.diggs at gmail.com
Tue Aug 26 01:25:20 CEST 2014
On 8/25/2014 2:08 PM, Jonathon Love wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> hey,
>
> i was able to solve the problem by explicitly putting
>
> R_LIBS_USER=''
>
> in the /etc/Renviron file (it isn't enough simply to comment the entry
> out, because it has a default value that magically comes from
> somewhere else)
It is worth pointing out that what you have done is removed the personal
library from the default list of libraries. So when loading a library,
it won't be found in a (the) personal library. However, a user can
circumvent this easily if they wish, either by adding a directory to the
library path list via .libPaths() or by specifying lib.loc in a call to
library() (or a variety of other ways). In other words, a user can still
"load[...] user packages" with a little additional effort. For your use
case, this may be sufficient. But I didn't want you to have the
impression that this made it impossible to load additional packages.
> cheers
>
>
> On 25/08/2014 9:59 pm, David Winsemius wrote:
>>
>> On Aug 25, 2014, at 7:11 AM, Ista Zahn wrote:
>>
>>> On Mon, Aug 25, 2014 at 5:58 AM, Jonathon Love <jon at thon.cc>
>>> wrote:
>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
>>>>
>>>> Hi,
>>>>
>>>> I'm trying to prevent the loading of packages from the
>>>> 'personal library'
>>>
>>> Of behalf of the users you are about to cripple, please, do not
>>> do that!
>>
>> Hello jonathon and Ista;
>>
>> (I think this might be the first time I've seriously with Ista.)
>> I've been in the situation where I had multiple copies of packages
>> in 2 different libraries and wanted to do exactly what was
>> requested. I'm assuming that the "main" library directory is
>> something other than '~/Library/R/3.0/library' and permissions
>> allow packages to be accessed and placed there. A quick method
>> would simply be to execute this at the command line (or if it
>> needed to be repeated in .Rprofile) :
>>
>> .libPaths( .libPaths()[!which(.libPaths() ==
>> '~/Library/R/3.0/library')] )
>>
>> I suppose you could wrap some testing around this to prevent the
>> removal of that path if it were the only one or if it were the path
>> to the base and stats packages. Fo me this reports correctly that
>> my base package is not there:
>>
>>> grepl("~/Library/R/3.0/library" ,
>>> attr(packageDescription('base'), "file") )
>> [1] FALSE
>>
>> But this raises the question. Why is this happening and why don't
>> you just delete the directory?
>>
--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
More information about the R-help
mailing list