13

On our server, R 2.12.1 is installed following the instructions on http://cran.r-project.org/bin/linux/debian/ , using apt-get install etc etc.

Due to circumstances the old lenny machine hasn't been updated to the new stable debian, and it looks like this isn't about to happen soon. As some of the research here depends on the latest version of VGAM, we need the R 2.14.0 installed on debian. But in order to keep old code running, we can't just drop the R 2.12.1 (installing the VGAM 0.8.4 on this version gives errors).

So we need to install 2 R-versions. From the little I understood, if we just use apt-get upgrade the old version will be replaced by the new. I've been going through heaps of documentation, but I can't find the optimal way of doing so.

The only thing I could imagine now, is to try to build the latest R from source, but my colleagues were not very keen on that idea and prompted me to first look for another solution. Any info I missed, or is somebody willing to show me the little trick to get this done? If building from source is the solution, I'd like to hear about any pitfalls or possible problems.

Joris Meys
  • 106,551
  • 31
  • 221
  • 263
  • I don't think an apt/aptitude solution is possible. And if it is possible, it is likely more difficult and convoluted than just building from source, which I find to be very straight-forward and easy on Debian based Linux. Plus, you get to impress all your friends by compiling with the latest BLAS libraries, which is always fun, and very important. – jthetzel Dec 01 '11 at 15:46
  • An apt/aptitude solution *could* be possible if someone rewrites the entire Debian packaging to allow for multiple versions (as many packages such as eg Emacs or PostgreSQL do). I won't have time to do it, unfortunately. – Dirk Eddelbuettel Dec 01 '11 at 17:37
  • 1
    @jhetzel: Yet again a common misunderstanding. You do **not** compile again particular BLAS, you just swap them at run-time. Look for my gcbd package vignette on CRAN for some details. – Dirk Eddelbuettel Dec 01 '11 at 17:38

4 Answers4

8

You can install different versions of ANY software using proper compile flags. When you run the configure script with --help you should see an option to see the install root.

Take a look at

./configure --help
...
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]

so you could install R-2.14 to:

/usr/local/R/2.14

and you could install R-2.12 to:

/usr/local/R/2.12

when you launch the configure script do:

./configure --prefix=/usr/local/R/2.14

and so on.

oz123
  • 27,559
  • 27
  • 125
  • 187
5

As I mentioned in comments, this is theoretically possible just like some package families (Emacs, PostgreSQL, ...) allow multiple concurrent versions.

I cannot offer that right now as we use /usr/{share,lib}/R which conflicts. If I were to make that /usr/{share,lib}/R-$version and then use dpkg-alternatives to flip to a default preferred one, we could possibly do it. The problem is the transition. This feature is used by a minority of user, getting to it may introduce bugs for a majority til this is stable. Plus, I do not have the spare time (but if someone else wants to do it, please do so).

In the meantime, you can

  1. possibly use an advanced feature of dpkg and unpack to a local directory rather the default below / -- so /opt/R/oldversions/2.12.1 should be possible. R could even run, you need to redefine $RHOME accordingly.

  2. just build local variants into /usr/local if you really must

  3. if a particular CRAN / non-CRAN package claims to need a particular version of R, fix the damn package already! ;-)

Finally, this is a topic for r-sig-debian as eg the CRAN maintainer Michael and Johannes won't read this thread here.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Thx for the help yet again. I forgot about the mailing list, but I did remember you pass by here once in a while :). I'll keep it in mind. – Joris Meys Dec 01 '11 at 20:16
3

I think that if there is no debian repo that provides multiple versions, it is hard to keep two versions of R running smoothly without compiling R from source.

What I often do is install R in my home dir as our institute does not give us root privileges. To install a source version of R systemwide, you could install this in a separate directory (e.g. /opt/R2.14) and use:

./configure --prefix=/opt/R2.14/

The final step is to create a symbolic link to the R binary:

ln -s /opt/R2.14/bin/R /usr/bin/R2.14

Users can than start two versions of R (R and R2.14). Hope this helps!

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
  • Thx for the hint. I have to install it systemwide though. Our sysadmin left the building more than a year ago so I'm the 'volunteer' taking care of it now. With a biology degree and an extra masters in statistics, that's not that evident... – Joris Meys Dec 01 '11 at 15:41
  • I do something similar to keep R-devel in /usr/local. – Dirk Eddelbuettel Dec 01 '11 at 17:35
0

It's true that building R from source is very very easy (even I can do it!), as long as you know the following command to run first :

apt-get build-dep r-base

otherwise you might get missing library type errors from make. Thanks to Dirk posting that gem in the past. I haven't seen that in the manual, README or FAQ.

Then, it's just :

./configure
make

I suppose this might be a consideration for you then: does R use static or dynamic system libraries? Might a self-built R link to different libraries than the pre-packaged binary R? (I don't know). How much you go into that depends on how critical your application of R is I guess and which system libraries are critical to you.

Matt Dowle
  • 58,872
  • 22
  • 166
  • 224