[R-sig-Debian] installing/updating R packages: apt-get vs. install.packages() and .libPaths()

Dirk Eddelbuettel edd at debian.org
Sat Mar 11 04:01:43 CET 2006

[ Delayed, and the manually approved as Michael posted without being
  subscribed under this address. Please consider subscribing.  --Dirk ]

Hi Michael,

On 10 March 2006 at 11:14, Michael Friendly wrote:
| I recently had to rebuild my entire debian system to correct some severe 
| dependency 
| conflicts and security issues. 

That should only happen by accident or some sort of negligence. I have
systems that I continuously upgraded for many, many years without problems.
Mind you they are also behind firewalls and not quite as visible as a
yorku.ca machine ...

| I installed a new harddisk, linux kernel 
| and started from
| scratch, keeping my old disk mounted as /olddisk.  In the process I 
| switched from unstable
| to stable distros as recommended by a local sysadmin to avoid such 
| problems in the future.
| Now I want to be able to install and update R and R packages with ease 
| and with minimal
| confusion about different versions in different libraries, 

No problem so far.

| so that I can 
| (a) install new packages in a consistent way with my current R version, 

Ok. More on that below.

| (b)  install a new R version with apt-get install r-base, ...  

That is in conflict with your approach from the very first paragraph.  By the
suggestion of your sysadmin, you cannot install new R version as they may
create 'severe dependency conflicts and security issues'.  All kidding aside,
you either believe that 

  I)  you want a stable system so you don't install new software, not
      even R, or

  II) you need current software, maybe only R, so you're willing to make

II) is possible via the backports of current R version that are on CRAN. Just
don't tell your sysadmin....  If you point to the apt-get'able archive
provided by CRAN you get new Debian packages of new R releases withins days
of the R release.

| (c) run update.packages() or something equivalent
| to update all the packages coherently. 

Also possible.

|  I'm confused about where things go based on apt-get install 
| {r-base,r-cran}* vs install.packages()
| and whether I am running as root vs me.  If I want to update.packages() 
| I don't want to have
| to worry about whether I am currently root or me -- I just want to be 
| *me* and have it work.

That works _provided you prepare your territory__. This is unix, so "you"
can only write there if your root let's you write. So you could for example

i)   add yourself to group adm in /etc/groups
ii)  chgrp adm /usr/local/lib/R/site-library/
iii) chmod g+w /usr/local/lib/R/site-library/

Now you should be able to say (inside R) 

	> update.packages(lib.loc="/usr/local/lib/R/site-library/")

In fact, I just did that.  You may need ii) and iii) with an added -R so that
you are allowed to overwrite previously installed versions, if any:

iv)  chgrp -R adm /usr/local/lib/R/site-library/
v)   chmod -R g+w /usr/local/lib/R/site-library/

|  > .libPaths()
| [1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
| [3] "/usr/lib/R/library"
|  >
| "/usr/lib/R/library"   for apt-get install r-base, as root

Per a suggestion by Fritz and Kurt at one of the Vienna conferences, this
directory is reserved for everything from r-base-core and r-recommended (ie
boot, MASS, ...) and *nothing* else. So these would get updated via apt-get
and dpkg.

| "/usr/lib/R/site-library"    for apt-get install r-cran, as root

Per a suggestion by Fritz and Kurt at one of the Vienna conferences, this
directory is reserved for whatever R packages _Debian_ adds to the system.
So these would get updated via apt-get and dpkg as well.

| "/usr/local/lib/R/site-library"   for install.packages() as {me,root}

Per a suggestion by Fritz and Kurt at one of the Vienna conferences, this
directory is reserved for whatever the local user/admin installs.  I used to
do that as root, but the method I suggest above is actually nicer.  So yes,
you can do that provided you (as root) give yourself (as you) the proper

| My machine is single user; should I just give myself chmod g+w privs 
| under  /usr/lib/R/site-library
| and maybe /usr/lib/R/library?  What is the recommended discipline?

Only for /usr/local/lib/R/ as you need root permissions (or at least sudo) to
interact with apt-get / dpkg anyway.

I hope this is of help and wasn;t too terse.  We should expand this where
needed and maybe post it on the R Wiki or maybe even polish it up for a quick
one-pager in R News...

Best regards,  Dirk

Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison

More information about the R-SIG-Debian mailing list