Michael Friendly
2006-Mar-10 16:14 UTC
[R-sig-Debian] installing/updating R packages: apt-get vs. install.packages() and .libPaths()
I recently had to rebuild my entire debian system to correct some severe
dependency
conflicts and security issues. 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, so that I can
(a) install new
packages in a consistent way with my current R version, (b) install a new
R version with apt-get install r-base, ... (c) run update.packages() or
something equivalent
to update all the packages coherently.
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.
> .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
"/usr/lib/R/site-library" for apt-get install r-cran, as root
"/usr/local/lib/R/site-library" for install.packages() as {me,root}
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?
thx,
--
Michael Friendly Email: friendly at yorku.ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT M3J 1P3 CANADA
Dirk Eddelbuettel
2006-Mar-11 03:01 UTC
[R-sig-Debian] installing/updating R packages: apt-get vs. install.packages() and .libPaths()
[ 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
compromises.
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
permissions.
| 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
Gregor Gorjanc
2006-Mar-12 02:55 UTC
[R-sig-Debian] installing/updating R packages: apt-get vs. install.packages() and .libPaths()
Hi!
Nice explanation Dirk! I agree that a one-pager for R news would be
nice. I am posting the following code, which can warn you about multiple
copies of packages. Using different installation systems has also some
of its drawback. You can easily end up with "several" copies of
packages
and you might know which one is loaded after library() is issued - order
is as in .libPaths()
tmp <- table(dir(.libPaths()))
tmp <- tmp[names(tmp) != "R.css"]
test <- sum(tmp > 1)
if (test > 0) {
cat("\n Warning: you have multiple copies of the following
packages:\n")
print(tmp[tmp > 1])
}
--
Lep pozdrav / With regards,
Gregor Gorjanc
----------------------------------------------------------------------
University of Ljubljana PhD student
Biotechnical Faculty
Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si
SI-1230 Domzale tel: +386 (0)1 72 17 861
Slovenia, Europe fax: +386 (0)1 72 17 888
----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
you have no certainty until you try." Sophocles ~ 450 B.C.