Skip to content

Installing different versions of R simultaneously on Linux

9 messages · Brian Ripley, Wacek Kusnierczyk, Rainer M Krug +1 more

#
Hi

I want to install some versions of R simultaneously from source on a
computer (running Linux). Some programs have an option to specify a
suffix for the executable (eg R would become R-2.7.2 when the suffix
is specified as "-2.7.2"). I did not find this option for R - did I
overlook it?

If it is not, how is it possible to have several versions of R on one
computer, or is the only way to compile them and then call R in the
directory of the version where it was compiled (~/R-2.7.2/bin/R)?

If this is the case, would it be possible to add this o[ptiuon to
specify the suffix for the executables?

Thanks

Rainer
#
G'day Rainer,

On Fri, 27 Feb 2009 09:34:11 +0200
Rainer M Krug <r.m.krug at gmail.com> wrote:

            
What flavour of Linux are we talking about?
For Debian based machines (I first used Debian, nowadays Kubuntu), I
got into the following habit:

1) Unpack the R sources in /opt/src
2) Enter /opt/src/R-x.y.z and run configure with
   --prefix=/opt/R/R-x.y.z (and other options) 
3) Build R with checks and documentation from source and install.
4) Run in /opt/src a script that uses "update-alternative" install to
   install the new version and creates a link from /opt/R/R-x.y.z/bin/R
   to /opt/bin/R-x.y.z

I have /opt in my PATH, thus I can call any R version explicitly by
R-x.y.z.  

Typing R alone, will usually start the most recently installed
version (as this will have the highest priority) but I can configure
that via "sudo update-alternatives --config R".  I.e., I can make R run
a particular version.  Since the "update-alternative" step above also
registers all the *.info files and man pages, I will also access the
documentation of that particular R version (e.g., C-h i in emacs will
give me access to the info version of the manuals of the version of R
which is run by the R command).

Over time, typically when the linux system is upgraded, libraries on
which old R-x.y.z binaries relied vanish.  At that time I usually
delete /opt/R/R-x.y.z and remove that version from the available
alternatives.

HTH.  Let me know if you need more details.

Cheers,

	Berwin
#
Hi

On Fri, Feb 27, 2009 at 10:41 AM, Berwin A Turlach
<berwin at maths.uwa.edu.au> wrote:
Sorry - I am running SuSE on the machine where I need it.
OK - similar to what I did.
How do I do this? I usually call "sudo make install". Do I have to use
"update-alternative --install R-2.7.1 R 2" if I want to have R-2.7.1
aqs the second priority installed?
That is what I need - but I can't find update-alternatives in SuSE
Exactly what I would like to have.
Thanks a lot - now I just have to know how I can do it under SuSE. I
will keep this in mind and use it for my main cvomputer, which runs
Xubuntu.

Rainer

  
    
#
This is really an R-devel question.
On Fri, 27 Feb 2009, Rainer M Krug wrote:

            
'R' is not an executable, but a shell script.

You can use 'prefix' to install R anywhere, or other variables for 
more precise control (see the R-admin manual).  For example, we use 
rhome to have R 2.8.x under /usr/local/lib64/R-2.8 etc.

And you can rename $prefix/bin/R to, say, R-2.7.2, or link 
R_HOME/bin/R to anywhere in yout path, under any name you choose.

  
    
#
Prof Brian Ripley wrote:
depending on what is meant by 'executable'.

"Files that contain instructions for an interpreter
<http://en.wikipedia.org/wiki/Interpreter_%28computing%29> or virtual
machine <http://en.wikipedia.org/wiki/Virtual_machine> may be considered
executables" [1]
"The term might also be, but generally isn't, applied to scripts
<http://foldoc.org/index.cgi?scripts> which are interpreted by a command
line interpreter
<http://foldoc.org/index.cgi?command+line+interpreter>." [2]

try also

    file `which R`

which is likely, system-dependently, to say that it's *executable*
(independently of the access mode).

vQ


[1] http://en.wikipedia.org/wiki/Executable
[2] http://foldoc.org/index.cgi?query=executable&action=Search


vQ
#
G'day Rainer,

On Fri, 27 Feb 2009 10:53:12 +0200
Rainer M Krug <r.m.krug at gmail.com> wrote:

            
Sorry, I am not familiar with that flavour; before switching to Debian
(and Debian based distributions), I was using RedHat.  And before that
Slackware.
I do the "make install" step manually, the script just alerts the
system that another alternative for the R command was installed.

If memory serves correctly, the "alternatives" mechanism was developed
by Debian and adopted by RedHat (or the other way round).  I am not
sure whether SuSE has adopted this, or a similar system.

Essentially, for a command, say foo, for which several alternatives
exists, is installed on the system in, say /usr/bin/, as a link
to /etc/alternatives/foo and /etc/alternatives/foo is a link to the
actual program that is called.  

E.g. on my machine I have

berwin at berwin-nus1:~$ update-alternatives --list wish
/usr/bin/wish8.5
/usr/bin/wish8.4

which tells me that wish 8.5 and wish8.4 are installed and I could call
them explicitly.  /usr/bin/wish is a link to /etc/alternatives/wish
and /etc/alternatives/wish will point to either of these two programs
(depending on what the system admin decided should be the default, i.e.
should be used if a user just types 'wish').  

A command like "update-alternatives --config wish" allows to configure
whether "wish" should mean "wish8.5" or "wish8.4".  And all that is
necessary is to change the link in /etc/alternatives/wish to point at
the desired program.
As I said, I do not know whether SuSE offers this alternatives system
or a similar system.  If it does, perhaps it is just a matter of
installing some additional packages?  If it offers a different, but
similar system, then you would have to ask on a SuSE list on that
system is maintained and configured.

On my machine I would say "apt-file search update-alternatives" to find
out which package provides that command and to install that package if
it is not yet installed.  I am afraid I do not know what the equivalent
command on SuSE is.
Well, if you ever use a system that has the alternatives set up and the
update-alternatives command, I am happy to share my script with you. 

Cheers,

	Berwin
#
On Fri, Feb 27, 2009 at 12:37 PM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
sorry about the wrong list.
OK - so the proceuder will be: if I want to install R 2.7.2 without
impacting on my existing installation of R (which is done by a package
manager), I use
and when I use
it will start R 2.7.2

I can continue with as many installed version as I want

Thanks a lot,
that was what I was looking for

Rainer

  
    
#
On Fri, Feb 27, 2009 at 1:49 PM, Berwin A Turlach
<berwin at maths.uwa.edu.au> wrote:
Thanks a lot for the offer - that would be great. I will set it up the
same way on m y PC with Xubuntu.

Cheers

Rainer

  
    
#
G'day Rainer,

On Fri, 27 Feb 2009 14:06:20 +0200
Rainer M Krug <r.m.krug at gmail.com> wrote:

            
Script is attached.  Ignore the comments at the beginning they are
there just to remind me what ./configure line I usually use, possible
variations, and whether to edit config.site or work with environment
variables.

After the "make install" step, I edit in this file the variable VERSION
and PRIORITY and then ran the script as root.  Note that VERSION should
be the same number as the one specified in the ./configure line.  

As long as the the configuration of a command is set to 'auto', the
alternative with the highest priority is used.  So make sure that the
newest version of R has highest priority, I usually set priority just
to xyz for R-x.y.z (and keep my fingers crossed that there will never
be a release with either y or z larger than 9, otherwise I will have
to refine my scheme).

To use this on a new machine, you have to create /opt/info, 
/opt/man/man1 and /opt/bin before running the script the first time
(IIRC).  It also helps to copy /opt/R/R-$VERSION/share/info/dir
to /opt/info/dir so that emacs will include the info files in the list
that you get with C-h i (this has to be done only once, the dir file
does not seem to change between R versions).

Prior to 2.5.0 the man and info files were installed in R-$VERSION/man
and R-$VERSION/info instead of R-$VERSION/share/man and
R-$VERSION/share/info, respectively.  I have a separate script for those
versions (but don't install such old versions anymore).  How far do you
want to go back?  Also, much earlier, if memory serves correctly,
R-exts.info came in 2 parts instead of 3; but I don't seem to have my
script from that time anymore.

I think that's all.  Let me know if you run into troubles or need more
help.

Cheers,

	Berwin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: R-Install
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090227/fc458dd7/attachment-0001.pl>